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 a satellite assembly in c#?
What is extension method in c sharp?
What to implement on my class Finalize or IDisposable
How do you prevent a class from being inherited?
What are managed providers?
What is a jagged array?
How to rotate an Image in C#?
What is use of abstract class in c#?
What is the difference between var and dynamic types in c# 4.0?
How to use nullable types in .net?
What is meant by unicode characters?
Describe the types of comments in c#?
How can you achieve run time polymorphism in C#?
What is type cast in C#?
How many types of polymorphism are there?