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?

Answer Posted / 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.
class A
{
private A()
{
C.w.l(" Hi");
}
public static display()
{
return new A();
}
S V M ( S[] args)
{
A a=a.display()
}

}

Is This Answer Correct ?    1 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is class reference type c#?

523


What is boxing in c#?

547


What is the use of thread join in c#?

490


How do I enforce const correctness in c#?

526


Is linkedhashset synchronized?

556






List some of the common data providers for ado.net framework?

448


what is IEquatable

553


Why do we use readonly in c#?

483


Explain the process of Serialization?

540


Are all methods virtual in c#?

530


What is the use of command builder?

527


What is the difference between icomparer and icomparable in c#?

456


What is AutoMapper in C#?

572


What is the difference between struct and class c#?

472


Explain the process of inheriting a class into another class?

483