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

What is the difference between firstordefault and first?

0 Answers  


I need code to connect ohter systems in the LAN and i want to display my website image over there and i want explain as a admin through phone. So i need code to access other system using C-Sharp. Any one please help me.Please give me the code. Advace thanks.

0 Answers   Excel,


What is a satellite assembly in c#?

0 Answers  


What is escape character in c#?

0 Answers  


What is int32 maxvalue?

0 Answers  






What is dapper in c#?

0 Answers  


what are the Disadvantages of vb

0 Answers   Digital GlobalSoft,


What does readonly mean in c#?

0 Answers  


Can you declare the override method static while the original method is non-static?

2 Answers   Mind Tree,


What?s the .NET datatype that allows the retrieval of data by a unique key?

1 Answers  


When compiler adds a default constructor to a class?

4 Answers   TCS,


Can we extend static class in c#?

0 Answers  


Categories