Cached property vs Lazy

后端 未结 7 1339

In .NET 4 the following snippet with a cached property can also be written using the System.Lazy class. I measured the performance of both approaches and it\'s pret

7条回答
  •  无人及你
    2020-12-04 13:58

    Use Lazy, as it expresses exactly what you are doing - lazy loading.

    In addition, it keeps your property very clean and is thread safe.

提交回复
热议问题