在完成readernew = reader
之后,在下面的代码中,然后如果我们进行readernew.ReadToFollowing
,这也在改变阅读器对象。它是如何发生的?即使将读取器对象复制到另一个对象后,ReadTo之后要同时更改两个实例。如何防止呢?
XmlReader reader = XmlReader.Create(path, settings);
XmlReader readernew = XmlReader.Create(path, settings);
state = State.TestERS;
newSite = new Sites();
NetWork.sites.Add(newSite);
newSite.sitename = reader.GetAttribute("id");
readernew = null;
readernew = reader;
readernew.ReadToFollowing ("xn:Container");
reader.ReadToFollowing("xn:Element");
reader.ReadToFollowing("xn:Container");