Can we have private constructor in our class file. When we
are trying to create instance for the class will it create
or throw error regarding that?
Answers were Sorted based on User's Feedback
Answer / nevin jain
yes off-course instance can be created...
just make a static function say ReturnInstance() within the
class n keep return type of this function as the name of the
with in ReturnInstance() method return the object of the class..
As the method is static so it will load without using
instance n now we can assign the object(or instance)to the
variable of class type...
public class A
Console.Writeline("Instance is created");
public static A ReturnInstance()
return new A();
public void Display()
Console.WriteLine("Display is accessed");
public static void main()
|Is This Answer Correct ?||4 Yes||1 No|
Answer / balamurugan
we can create private constructor.it wont throw any
execption..but we cant create object for that class
|Is This Answer Correct ?||3 Yes||3 No|
Answer / vijay rana
we can declare objects in csharp,
but we can not create any instance of this class ,
if we do so it will throw an exception;
|Is This Answer Correct ?||4 Yes||4 No|
Answer / saiish bhat
ya,we have private constructor.but it wont throw an exception.
but u cant create an instance of p.c.
it is not possible to inherit from that class also.
private class a()
class b : a
|Is This Answer Correct ?||1 Yes||2 No|
Answer / ranjeet saini
it does not throw an exception
bcoz we can create private constructor if we have static member in class
in this we can create a reference object with the help of static method.
public static display()
return new A();
S V M ( S args)
|Is This Answer Correct ?||1 Yes||4 No|
What happens if a static constructor throws an exception?
in a town the percentage of total men is 52. the percentage of total literacy is 48. if total percentage of literate men is 35 of total population. write a program to find out the total no of illiterate men and women.
Does c# replace c++?
what is uniary operators and binary operators and what is the difference
How do you create multiple inheritance in C#?
Overloaded constructor will call default constructor internally?
what are the Disadvantages of vb
what is scope of a protected internal member variable of a c# class
Difference between dispose and destructor?
What is monitor in C#?
How do you create dlls in .NET
How do I do a case-insensitive string comparison?