I think I may use the Using statement here incorrectly. What would be the best way to write this?
Dim x As New Serialization.XmlSerializer( ... ) Using file As New FileStream(myFile, FileMode.Create) Using writer As XmlWriter = XmlTextWriter.Create(file) x.Serialize(writer, myCollection) End Using End Using
I read that you should only use the using block for objects with .Dispose() (i.e., implements IDisposable), so I think there should not be a "Use on," writer, but instead writer.Close() at the end, but the βfileβ has both .Dispose() and .Close() , so I use? using or file.Close() ?
Note. I use XmlWriter because I can customize the output. However, I deleted the settings.
grant source share