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


Please Help Members By Posting Answers For Below Questions

Enlist some of the properties of a thread class?

513


In gridview in editmode if we want to display information in one combobox based on

1823


Is struct object oriented?

480


What are the steps for creating clr trigger

569


What is a destructor in c#?

525






Is std :: string null terminated?

492


What is the c# equivalent of c++ catch (...), Which was a catch-all statement for any possible exception?

500


What are the examples of data types?

488


How do you use nullable?

504


Why dataset is used in c#?

513


What is protected internal modifier in C#?

514


What are the different types of literals in c#?

508


What is the reason behind the invention of c#?

635


What is a jagged array?

495


How can you prevent escaping on backslashes in C# with string definitions?

700