Static constructor in C#
In this article, we will learn about static constructor in C#.
Static constructor is a special method that called before when the first object of the class is created. Static constructor is used to initialize only static data.
Some important points about static constructor
- It is used to initialize static data members.
- A static constructor does not take access modifiers.
- A static constructor can not have parameters.
- A static constructor cannot be called directly.
- The user has no control on the static constructor is executed in the program.
Console.WriteLine("My name is Rahul");
static void Main()
//Static Constructor is invoked for first instance.
Test T1 = new Test();