0
鑑於這種XML元素:自定義序列化/反序列化問題
<SampleA>0</SampleA>
爲什麼reader.HasValue
解析爲假時,該元素顯然有一個值(「0」)?
if (reader.HasValue)
this.SampleA = Int32.Parse(reader.ReadElementString("SampleA"));
這是檢查上述目的的正確屬性嗎?
鑑於這種XML元素:自定義序列化/反序列化問題
<SampleA>0</SampleA>
爲什麼reader.HasValue
解析爲假時,該元素顯然有一個值(「0」)?
if (reader.HasValue)
this.SampleA = Int32.Parse(reader.ReadElementString("SampleA"));
這是檢查上述目的的正確屬性嗎?
這可能是因爲您的讀者在另一個節點上。
您可能也想嘗試:
if(reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "SampleA") {
}
謝謝你,是什麼的localName和姓名之間的區別?我看到一個是合格的,另一個是本地名稱,這些是什麼意思? – TheWolf 2011-05-13 01:42:13
AFAIK QualifiedName包含名稱空間(前綴:LocalName),而LocalName只是名稱。希望這可以幫助。 – YetAnotherUser 2011-05-13 01:50:19