0

MyValue是否可以使用is反序列化 XML 文件0x0001并将其反序列化为 uint 属性?实现这一点的最佳方法是什么?

public class MyClass
{
    private string myValue;
    public uint MyValue
    {
         //checkValue method checks if myValue is a decimal or hex and number (returns an uint value).

         get { return checkValue(myValue); } 
         set { myValue = value.ToString(); }

    }
}
4

1 回答 1

0

怎么样:

public class MyClass
{
    private uint? _myValue;
    [XmlIgnore]
    public uint MyValue
    {
        get{ return _myValue ?? checkValue(MyValueString); }
        set{ _myValue = value; }
    }    

    [XmlElement("MyValue")]
    public string MyValueString
    {
         //checkValue method checks if myValue is a decimal or hex and number (returns an uint value).
         get; set;
    }
}
于 2013-01-14T10:40:16.980 回答