非序列化字段与反序列化完成后回调

示例:

public class Class1 : IDeserializationCallback

{

    public DateTime Birthday { get; set; }

    [NonSerialized]

    public int Age;

    public void OnDeserialization(object sender)

    {

        Age = DateTime.Now.Year - Birthday.Year;

    }

}

 

你可能感兴趣的:(反序列化)