Static constractors in C#

Question posted in Computer Software on 02 2010
Rate question difficulty level 1 Votes
Are static constractors exists in c#? if so, what they used for?
 
 
1 Answer
 
Static constructor is used to initialize static data members as soon as the class is referenced first time, whereas an instance constructor is used to create an instance of that class with keyword. A static constructor does not take access modifiers or have parameters and can't access any non-static data member of a class.

Since static constructor is a class constructor, they are guaranteed to be called as soon as we refer to that class or by creating an instance of that class.


02/11/2010
 
 
Add an answer*
 
Email
Company: Microsoft
Location: Hertzliya , Israel
C# ctor static
Now hiring!
Intuit 
---------------------------
---------------------------
---------------------------
---------------------------
---------------------------
---------------------------
---------------------------