Home > DeveloperSection > Interviews > What is a static constructor?

Posted on    September-19-2014 11:55 PM

 C# .NET  C# 
 1 Answer(s)
  801  View(s)
Rate this:

Sumit Kesarwani

Total Post:782

Posted on    September-19-2014 11:55 PM

Static constructors are introduced with C# to initialize the static data of a class. CLR calls the static constructor before the first instance is created.


The static constructor has the following features:

No access specifier is required to define it.

You cannot pass parameters in static constructor.

A class can have only one static constructor.

It can access only static members of the class.

It is invoked only once, when the program execution begins.

Don't want to miss updates? Please click the below button!

Follow MindStick