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 we put script in head of asp.net page Why not in body?

1 Answers  


Why does dllimport not work for me?

0 Answers  


What is difference between constants and read-only?

0 Answers  


What is polymorphism c# example?

0 Answers  


what are the events in delegate?

2 Answers   Choice Solutions,






Name some properties of array.

0 Answers  


What is string interpolation in c#?

0 Answers  


What is datatable in c#?

0 Answers  


Did it possible to cast a generic type of derived class to generic type of base class?

2 Answers   TCS,


code to generate a excel sheet and to write data into it --- -it has to fetch the excel sheet which is in one folder placed by us inside a project folder(i,e it has to create a instance of that excel sheet) and write the data into it row by row please respond as early as possible

1 Answers  


How can you overload a method?

6 Answers  


What are extender provider components?

0 Answers  


Categories