class A
{
int x;
public static int y;
//static initializer
static A()
System.Console.WriteLine("Static initializer");
}
//constructor
public A()
System.Console.WriteLine("Constructor 1");
public A( int x )
this.x = x;
System.Console.WriteLine("Constructor 2");
public A( int x, int y )
this.x = x; //without using 'this', parameter has greater preference. Hence it makes a meaningless statement
A.y = y;
System.Console.WriteLine("Constructor 3");
public class Program
public static void Main()
A.y=30;
A obj = new A();
A obj1 = new A();
A obj2 = new A(10); //compile time polymorphism
A obj3 = new A(20,30); //compile time polymorphism
//steps:
//1. Allocate memory for y
//2. Call static initializer
//3. Allocate memory for new instance obj
//4. Call non static initializer
//etc...