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

Explain About multi level and multiple inheritance how to achieve in .net

824


What is datetime minvalue in c#?

805


Why are strings immutable c#?

680


Name the property of the textbox which cannot be changed at runtime?

745


What is a linked list c#?

715


What is a generic in c#?

720


Can I define a type that is an alias of another type (like typedef in c++)?

796


What is var c#?

710


Explain the 3 types of properties in c# with an example?

768


What is an object and a class?

805


What is the use of getcommandlineargs() method in c#.net?

763


What is boxing in c#?

798


What are events in C#?

769


Can an abstract class inherit from another abstract class c#?

759


Where do we use static class in c#?

702