Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to dispose/close XDocument.Load(string)?

I can't find any info about whether or not I should dispose/close this object after using it... Here is the msdn link: http://msdn.microsoft.com/en-us/library/bb343181.aspx

like image 859
Wagner Danda da Silva Filho Avatar asked Sep 09 '10 20:09

Wagner Danda da Silva Filho


2 Answers

No, you don't - it doesn't even implement IDisposable. The XDocument and XElement classes use XmlReader under the covers and handle the disposing of the underlying reader for you.

like image 50
Andrew Hare Avatar answered Oct 06 '22 22:10

Andrew Hare


Easiest way to find out is to look if it implements IDisposable

like image 45
Bertvan Avatar answered Oct 07 '22 00:10

Bertvan