What is the use of the static constructor? When static
constructor gets compiled?
Answer Posted / jitendra
Static constructor is used to initzialise the static data
members when the class has been instantiated first time.
Static data members can certainly be initialized at the
time of their declaration but there are times when value of
one static member may depend upon the value of another
static member. In such cases we definitely need some
mechanism to handle conditional initialization of static
members. To handle such situation, C# provides static
constructor.
| Is This Answer Correct ? | 20 Yes | 2 No |
Post New Answer View All Answers
Difference between call by value and call by reference in C#?
What is callback method in c#?
What is callback function in c#?
What is jit? What are the different types of jit?
What is the object class in c#?
What is argument in c#?
Why do we use classes?
why delegate is type safe?
Where’s global assembly cache located on the system?
What is an enumerator c#?
Howmany five tracing levels in System.Diagnostics.TraceSwitcher? Why they are using?
What is a jagged array?
How can I access the registry from c# code?
What is before string in c#?
Are structs faster than classes?