Constructor (object-oriented programming): Difference between revisions

Content deleted Content added
Flyer22 Frozen (talk | contribs)
m Reverted edits by 14.141.78.211 (talk) to last revision by 99.13.192.9 (HG)
Line 186:
Static constructors allow complex static variable initialization.<ref>[http://msdn.microsoft.com/en-us/library/k9x6w0hc%28VS.80%29.aspx Static Constructor in C# on MSDN]</ref>
Static constructors are called implicitly when the class is first accessed. Any call to a class (static or constructor call), triggers the static constructor execution.
Static constructors are [[thread]] safe]] and implement a [[singleton pattern]]. When used in a [[generic programming]] class, static constructors are called at every new generic instantiation one per type. Static variables are instantiated as well.
 
<source lang="csharp">