开发者

Custom Serialization/De-serialization Issue

开发者 https://www.devze.com 2023-03-05 07:57 出处:网络
Given this XML element: <SampleA>0</SampleA> Why is reader.HasValue resolving to false when the element clearly has a value (\"0\")?

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

精彩评论

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