Hi I was doing some R&D on
Constructor of
C# class . I found that when we use a
public and a
private constructor in the same class I must overload them . i.e the signature must be different. But when I place a static constructor I can place it with the same signature . The sample code is given bellow . Please tell me how it is possible.
class C1
{
static Double pi;
public C1()
{
Console.WriteLine("Constructor :" + "C1");
}
C1(string s)
{
Console.WriteLine("Private Constructor :" + s);
}
static C1()
{
pi = 3.14;
}
public void m1()
{
Console.WriteLine("Method :" + "M1 " + pi.Tostring() );
}
}
class Program
{
static void Main(string[] args)
{
C1 c = new C1();
c.m1();
Console.ReadLine();
}
}