Constructor (object-oriented programming): Difference between revisions

Content deleted Content added
m Reverted edits by 150.104.250.202 (talk) (HG)
Line 206:
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 ur gayare [[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">