namespace Consolepractice
{
class Program {
public static void Main(string[] args) {
Test.x = 1;
//The static constructor for a class executes before any of the static members for the class are referenced.
Console.WriteLine("static member value:" + Test.x);
Test ob1 = new Test();
Test ob2 = new Test();
Console.WriteLine();
Console.ReadKey();
}
}
class Test {
public static int x;
public Test() // It will be executed every time when we create the object
{
Console.WriteLine("Default Constructor");
}
//There should at most one Static Constructor in a class and also Static Constructor can't take any parameters or access modifiers.
// It will be executed only once
//The static constructor for a class executes before any instance of the class is created.(before default constructor)
static Test() {
Console.WriteLine("static Constructor");
}
}
} // This is just a sample script. Paste your real code (javascript or HTML) here.
if ('this_is' == /an_example/) {
of_beautifier();
} else {
var a = b ? (c % d) : e[f];
}This code snippet is for static constructor in C#.
