Lazy initialization in .NET 4

前端 未结 3 1015
我寻月下人不归
我寻月下人不归 2021-01-31 17:29

What is lazy initialization. here is the code i got after search google.

class MessageClass
{
    public string Message { get; set; }

    public MessageClass(st         


        
3条回答
  •  旧时难觅i
    2021-01-31 18:13

    "Lazy initialization occurs the first time the Lazy.Value property is accessed or the Lazy.ToString method is called.

    Use an instance of Lazy to defer the creation of a large or resource-intensive object or the execution of a resource-intensive task, particularly when such creation or execution might not occur during the lifetime of the program."

    http://msdn.microsoft.com/en-us/library/dd642331.aspx

提交回复
热议问题