What is private constructor? What is the use of it?

 Posted by Rajni.Shekhar on 4/3/2012 | Category: C# Interview questions | Views: 1981 | Points: 40

Private constrors are the special kind of constructor, which are allowed to not set create instace of a class from outside of the class. They are basically created when a class only have static members.

when you want to craete a single instance of class than use private constructor, basically they are used for Singlton pattern also.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response