c# - EnsureLocalDisposalRule for XmlNodeList -


when run gendarme 2.11 on c#.net project following code triggers ensurelocaldisposalrule:

xmldocument myxmldoc = this.getxmldoc(); foreach (xmlnode mynode in myxmldoc.getelementsbytagname("tagname")) {     ... mynode ... } 

with message:

local of type 'xmlnodelist' not disposed of (at least not locally).

after reading rule description attempted rewrite follows:

xmldocument myxmldoc = this.getxmldoc(); using (xmlnodelist mynodelist = myxmldoc.getelementsbytagname("tagname")) {     foreach (xmlnode mynode in mynodelist )     {         ... mynode ...     } } 

but gives error:

'system.xml.xmlnodelist': type used in using statement must implicitly convertible 'system.idisposable'

what causing this? bug in gendarme? or have misunderstood rule? how code improved?


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -