Reputation: 35605
In what situations do I initialize a class using a static constructor?
Upvotes: 1
Views: 88
Reputation: 11820
From here:
A static constructor is used to initialize any static data, or to perform a particular action that needs performed once only. It is called automatically before the first instance is created or any static members are referenced.
Upvotes: 4
Reputation: 1039498
When your class uses some static members that need to be initialized or when you want to ensure that some initialization code specific to this class is guaranteed to be executed only once for the entire lifetime of the AppDomain.
Upvotes: 0