Content deleted Content added
m →Default constructors: Wkf. |
Citation bot (talk | contribs) Added date. | Use this bot. Report bugs. | Suggested by Dominic3203 | Linked from User:LinguisticMystic/cs/outline | #UCB_webform_linked 417/2277 |
||
Line 149:
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.<ref name=Skeet>{{cite book |last=Skeet|first=Jon|title= C# in Depth |date=23 March 2019 |publisher= Manning |isbn= 978-1617294532}}</ref>{{rp|38}}<ref name=Albahari>{{cite book |last=Albahari |first=Joseph |title= C# 10 in a Nutshell |publisher= O'Reilly |isbn= 978-1-098-12195-2}}</ref>{{rp|111}} Static variables are instantiated as well.
<syntaxhighlight lang="csharp">
|