C# Static Constructor
A static constructor in C# is a static data initializer. Static constructors allow complex static variable initialization.[1] Static constructors can be called once and call is made implicitly by the run-time right before the first time the class is accessed. Any call to a class (static or constructor call), triggers the static constructor execution. Static constructors are thread safe and are a great way to implement a Singleton pattern. When used in a Generic programming class, static constructors are called on every new generic instantiation one per type (static variables are instantiated as well).
[edit] Static Constructor Example
GeSHi (C#):
public class MyClass
{
private static int _A;
//normal constructor
static MyClass()
{
_A = 32;
}
//standard default constructor
public MyClass()
{
}
}
виждал съм нещо подобно и в един урок за рнр 5.3 на скоро. Обаче не съм се заглеждал много много. Помня че нещо извикваха само веднъж но наистина не знам защо. Това ги изчегъртах от едно уини