No. You're not doing anything wrong.
You can only use the using statement with classes that implement the
IDisposable interface. The XmlTextWriter doesn't implement that interface,
hence the error message.
The work around is to do what the C# complier does for using statement:
XmlTextWriter writer = ...
try
{
// do wtuff with the writer
}
finally
{
writer.Close();
}
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"Russell Mangel" <ru*****@tymer.net> wrote in message
news:OJ**************@TK2MSFTNGP10.phx.gbl...
Is it possible to use the using statement with XmlTextReader?
I tryed to use it, but it gives me the error message:
Cannot implicitly convert type 'System.Xml.XmlTextReader' to
'System.IDisposable'
Is there something I am doing wrong?
// This no worky
using(XmlTextReader xtr = new XmlTextReader("C:\\myfile.xml"))
{
// Do something
}