When I checked the implementation of Lazy<T>
class, I saw this block:
[OnSerializing]
private void OnSerializing(StreamingContext context)
{
T obj = this.Value;
}
As you can see it's forcing initialization during serialization. Does anyone know why this behavior is preferred as default?
if it doesnt and you provided lambda for initialization, where do you think it retrives the value on deserializing? lambdas are not serializable.