Daljeet Singh
What is the use of Private Constructor in a Class?
By Daljeet Singh in C# on Sep 25 2012
  • NitRiX Reloaded
    Oct, 2012 2

    1.) To initialize the private variables in a class. 2.) Also to ensure or prevent user from creating instance of a class. Similar to singleton pattern in which - class object will be created internally and passed in through a Public static property etc. So developer will not be able to create instance by calling default constructor.

    • 0
  • Sandeep Singh Shekhawat
    Sep, 2012 28

    Its use whe we are using singleton pattern in application development. Its bind to developer to can not create another instance if already one instance exist and its also restrict developer to create default instance of class.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS