|
If your class declares a static constructor, you are guaranteed that the static constructor will run before any instance of your class is created. Eg. -
public class Time { private static string Name;
static Time () { Name = "Time"; } }
Notice that there is no access modifier before the static constructor. Access modifiers are not allowed on static constructors. In addition, because this is a static member method, you can not access non-static variables and so Name must be declared a static member variable.
|