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 |
What is difference between static and readonly in c#?
Which are the access modifiers available in c#?
What is Private Constructor? and it’s use? Can you create instance of a class which has Private Constructor?
What is the use of console readline () in c#?
Can we override interface method?
How to find the current application file path while runtime?
What is extension method in c sharp?
If you define a user defined data type by using the struct keyword, is it a value type or reference type?
If you donot specify an access modifier for a method, what is the default access modifier?
What is the difference between dispose() and finalize() methods in c#?
What is regex replace in c#?
if you do have a stack overflow profile.what is your ranking?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)