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
What is dbcontext c#?
What is lazy keyword in c#?
Can you instantiate a struct without using a new operator in c#?
What are the features of c#?
What is the purpose of a console table?
Is c# difficult to learn?
What are the differences between value types and reference types?
What is xamarin used for?
What is the use of private constructor in c#?
What is different between Static Constructor and Private Constructor?
How does bitwise work?
What is returned if you pass the value 12.34 to the parsefloat () function?
Why do we use void in c#?
What is sqlcommand in c#?
Do unused Namespaces in c# affect run-time performance?