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
Do extension methods have to be static?
What is a console operator?
What is the use of console readkey in c#?
Why is aws serverless?
What is difference between private, protected, and public in C#?
What is delegate in c# interview questions?
What is the purpose of dependency injection?
What is the value which is accepted by all data types ?
What is the different types of private assembly and shared assembly?
Can you create partial delegates and enumerations?
What is type cast in C#?
What is default method in c#?
How do you read an Excel sheet in C#?
Can property be private in c#?
What is the difference between an integer and int?