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 window application in c#?

0 Answers  


Explain the difference between Metadata and Manifest

0 Answers   HCL,


what are the contents of an assembly ?

0 Answers  


How do I register my code for use by classic com clients?

0 Answers  


Why c# is type safe?

0 Answers  


From a versioning perspective, what are the drawbacks of extending an interface as opposed to extending a class?

0 Answers  


Explain About a class access specifiers and method access specifiers.

0 Answers  


What Is The Difference Between ViewState and SessionState?

1 Answers   Fiserv,


Why ienumerable is used in c#?

0 Answers  


What is dynamic object in c#?

0 Answers  


Which class comes after the SortedList class?

0 Answers   Siebel,


What is a multicast c# delegate?

0 Answers  


Categories