开发者

Custom Serialization/De-serialization Issue

Given this XML element:

<SampleA>0</SampleA>

Why is reader.HasValue resolving to false when the element clearly has a value ("0")?

if (reader.HasValue)
    this.Sam开发者_JS百科pleA = Int32.Parse(reader.ReadElementString("SampleA"));

Is this the correct property to check for the above purpose?


This could be because your reader is on another node.

You may want to try:

 if( reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "SampleA") {
   }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜