What is a static constructor

What is a static constructor and also explain its features?

E

Expert

Verified

Static constructors are set up with C# to initialize a static data of the class. CLR calls a static constructor before first instance is created.
The static constructor has the following features:

i.    A class can have only single static constructor.
ii.    Access specifier is not required to define it.
iii.    It can access only static members of the class.
iv.    It is invoked only one time, when a program execution begins.
v.    We cannot pass parameters in the static constructor.

   Related Questions in DOT NET Programming

©TutorsGlobe All rights reserved 2022-2023.