Why do we need private constructor in c#?



Why do we need private constructor in c#?..

Answer / Desh Deepak Srivastava

Private constructors in C# are used to prevent instantiation of a class from outside the class. This is particularly useful when creating classes that should act as base classes, utility classes, or singleton classes, where you want to ensure only one instance exists.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Explain how is the dll hell problem solved in .net?

1 Answers  


Difference between abstract classes and interfaces

1 Answers  


What is the difference between ref and out in c#?

1 Answers  


what is c# command?

1 Answers  


Can we define a variable with the access modifier private in an interface?

7 Answers   IBM,


How can I get the ascii code for a character in c#?

1 Answers  


What is lazy keyword in c#?

1 Answers  


how many catch we can write in thye program?

2 Answers  


What?s the difference between the Debug class and Trace class?

2 Answers  


what are the differences between a class and structure

1 Answers   Cognizant,


What does it mean?

1 Answers  


How do you generate documentation from the C# file commented properly with a command-line compiler?

1 Answers  


Categories