We define a constructor private in the following scenarios:-
• We want to restrict the client to not create objects.
• In case of singleton patterns where we want only instance of the object to be created.
Below is a simple video which explains the above concept practically.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizk2_SGcWeVfeaRgoxtobBqsKJTZuV6qWszeIH-VVGeyKTqa9kEiM3zlUa2vcxbzzBSbNBuJ1N5gb0VTOENgMWa7yEwBgwBzOnRjQGnHA9E02I_Ex4Dyxk27sKCzaGQTp-JcZLcy4LKQ/s400/V2.JPG)
Please click here to see more Most asked c# interview questions
• We want to restrict the client to not create objects.
• In case of singleton patterns where we want only instance of the object to be created.
Below is a simple video which explains the above concept practically.
Please click here to see more Most asked c# interview questions
No comments:
Post a Comment