What is the use of the static constructor? When static
constructor gets compiled?



What is the use of the static constructor? When static constructor gets compiled?..

Answer / 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

More C Sharp Interview Questions

Why is it a bad idea to throw your own exceptions?

4 Answers  


How do I do a case-insensitive string comparison?

0 Answers  


What is a jagged array?

0 Answers  


What does exclamation mark mean c#?

0 Answers  


What you mean by inner exception in c#?

0 Answers  


Ho we can see assembly information?

0 Answers  


What does assert() do?

1 Answers   Rolta,


What is strongly typed in c#?

0 Answers  


what is main function of alternate teamplate of datalist?

0 Answers  


What are the access-specifiers available in c#?

26 Answers   Syntel,


Why is c# better than java?

0 Answers  


What is use of list in c#?

0 Answers  


Categories