Top

How to perform lazy initialization in C#

September 25, 2017

Lazy initialization is a technique that defers the creation of an object until the first time it is needed. In other words, initialization of the object happens only on demand. Note that the terms lazy initialization and lazy instantiation mean the same thing—they can be used interchangeably. By taking advantage of lazy initialization, you can improve the application’s performance by avoiding unnecessary computation and memory consumption. In this article we’ll look at how we can perform lazy initialization in C#.

Let’s understand lazy loading with a simple example. Consider two classes, Customer and Order.

Read More on InfoWorld