今天改一段code,发现ms guy这样得到一个XmlNode的Attribute:XmlNode attribute = node.Attributes.GetNamedItem("myAttribute");为什么不直接用 XmlAttribute attribute = node.Attributes["myAttribute"];于是就check了一下,发现XmlAttributeCollection的Indexer实际上是call GetNamedItem方法,然后做了一个转换:public virtual XmlAttribute this[string name]{ get { return (XmlAttribute) this.GetNamedItem(name); }} 而直接call GetNamedItem方法,就可以少转换一次。这样在循环处理xml文档的时候,可以一定程度的提高效率. :) 转载于:https://www.cnblogs.com/tongling/archive/2005/10/20/258392.html