In .NET 4 the following snippet with a cached property can also be written using the System.Lazy
Well if your performance is about the same then the only reason to use Lazy
over the cached version would be if you aren't sure if the user is actually going to load the property.
The point of Lazy
is to wait until the user needs the resource and then create it at that instance in time. If they are always going to need to resource then there is no point in using Lazy
, unless you need some of it's other purposes such as it being thread safe.