Click here to Skip to main content
15,910,009 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Colud i put XmlDocument doc = new XmlDocument() in side using method as below if not then why


Using(XmlDocument doc = new XmlDocument())
{
//-------

//---------
}

Thanks
Posted
Comments
phil.o 5-Sep-13 8:01am    
Cannot you just try and see ?
Your c# statement is valid (except 'using' keyword does not start with an uppercase letter)

1 solution

Hello,

To use using , the class you want to use must implement IDisposable.

XmlDocument does not implement it, so you can't do that.

http://msdn.microsoft.com/en-us/library/yh598w02.aspx[^]

Valery.
 
Share this answer
 
v3
Comments
phil.o 5-Sep-13 8:10am    
5! I did not check whether XmlDocument implements IDisposable interface, you're right to notice that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900