 Have you ever wondered that in Csharp you can defer the creation of an object until it is actually used? Hello there, this is Krish Raj Rana from Bytes Cow and in this video, we will be going to learn about how we can lazily initialize the objects using the newly introduced lazy keyword of Csharp. Well, with Csharp 0, Microsoft has introduced a lazy keyword using which initialization of the object happened only on demand and this feature comes to handy when we are working with large objects. So let's dive deeper and explore this lazy keyword by performing some demo. To perform a demo here, I have defined one console application in which I have defined one patient object class. Now if we have a look at this class, we can see that we have got our public default constructor and we are just writing out some information to the console using this console.write line. So overall, this is a very simple class which contains a fewer getter setter property for patient basic detail information. Now if we run this application, it simply creates an object and call its constructor and we get our message in the console like this. Now consider a situation where the creation of these objects in the constructor requires some resource intensive activity and if we don't always use all of the objects we create, we are still going to incur that cost when we create that objects. By using lazy initialization, the objects are not actually constructed until the first time we try to access them. Now to create a lazy version of this patient detail class, I need to use lazy class like this. Let me comment out this class and now to check whether the object of this class is created or not. There is one property called ease value created in this object using which we can check the object status. And now if I run this application and when I check this property value, you can see that this value is false. So even though we have executed this line, but the constructor of this class is still not been executed, which you can see in this console window. So now the question is how we can initialize the lazy object. Well, it's very simple for that. What you need to do is you just need to access the value property of this lazy object and then from here, let's call this method. And now this time, if I run this application, you can see that this property is now becomes true. And here you can see that first the constructor is called and then our method is called and then finally we get this message. Now what happened if we have an overload constructor that takes a patient ID as argument, something like this. So to execute this overload constructor, we can specify the constructing function of this lazy class like this. So as you can see that this overload take a function which creates a new patient detail object, but this time using the overload constructor that allows us to specify the patient ID. So now let's run this application and check the output. So here we can clearly see that this time the parameterized constructor is called with this patient ID. So here regardless of which of this constructor we use of this class, the actual initialization is not performed until the first time we access this value property. Now what if multiple thread are racing to initialize this object? We will learn that in the next video and we will also do some performance testing with this lazy class. So till then happy learning and stay tuned with us.