top button
Flag Notify
Site Registration

What is the use of private constructors in c#?

0 votes
223 views
What is the use of private constructors in c#?
posted Apr 3, 2017 by Sunil

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Private constructors are used to prevent creating instances of a class when there are no instance fields or methods, such as the Math class, or when a method is called to obtain an instance of a class. If all the methods in the class are static, consider making the complete class static.

answer Apr 17, 2017 by Shweta Singh
Similar Questions
+3 votes

By-default all the methods & variables in class are private.

In C#.net Main() method is private then how compiler access this Main() Method out side the class because compiler is not part of our program then how compiler access this Main() method?

Here we loose our data abstraction property ? Can anyone put some light on it?

+1 vote

What is the difference between

public static void Main()

and

private static void Main()

in C#?

...