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 extension method in c# and how to use them?
How to prevent the error while updating ui control from another thread?
Difference between StackPanel and RelativePanel ?
What is the difference between list and array in c#?
What are cookies in c#?
What are c# collections?
Define a partial class?
Is c# good for beginners?
What will a loop recorder show?
Can we store different data types in arraylist in c#?
What are the advantages of using delegates in c#?
What is instantiating a class in c#?
What is the difference between a function and a method?
Is it not possible to store a boolean value as a variable?
Why do we use delegates?