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

Posted on    September-04-2014 11:36 PM

 C# C# 
 1 Answer(s)
  664  View(s)
Rate this:

Sumit Kesarwani

Total Post:782

Posted on    September-04-2014 12:00 AM

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