I had the following class:
[Serializable]
public class Message
{ public string messageSummary;
public DateTime messageDate;
}
Later, i decided to add to the class another int field - messageNumber
[Serializable]
public class Message
{
public string messageSummary;
public DateTime messageDate;
public int messageNumber;
}
In deserialization, when deserializing an old serialized Message
class(without messageNumber
field) - how can I set the default value of messageNumber to -1 instead of 0?
I tried to define a method with [OnDeserialized()]
attribute, but messageNumber
is already set there to 0. 0 can also the value of messageNumber
, so I can't override it in that method.
Is it possible to set the default value to -1?
Thanks