【发布时间】:2017-02-14 13:06:46
【问题描述】:
我正在使用流创建一个 XmlDocument 并在 XmlDocument 中进行一些更改并将 XmlDocument 保存到流本身。
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(fileStream);
////
////
////
xmlDocument.Save(fileStream);
//how to dispose the created XmlDocument object.
现在如何销毁 XmlDocument 对象?
【问题讨论】:
-
xmlDocument = null;但你也可以让它超出范围。 GC 将完成剩下的工作。 -
'dispose'在C#中有特定的含义,与
IDisposable接口有关。它主要用于处理非托管资源。但这里不是这种情况。只要不再引用您的XmlDocument实例,它就可以进行垃圾回收。
标签: c# .net xmldocument