Question

Is it possible to deserialize a XML file with MyValue is 0x0001 and deserialize it to an uint property? What's the best way to implement this?

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(); }

    }
}
Was it helpful?

Solution

How about something like:

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;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top