About This eBook by Bart De Smet

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

Static Constructors

Where instance constructors take on the task of initializing a new object instance, the role of static constructors (sometimes referred to as type initializers) is to initialize a type’s static state. Although the runtime provides type initializers for more than just classes and structs, C# restricts their declaration to those categories of types (mainly because of their limited use of other types).

A static constructor looks like an instance constructor but is declared via the static keyword, doesn’t have an access modifier, and can’t take any parameters. Just like any other static member, it can only access other static members and is primarily used to assign the type’s static fields. In fact, static field initializers ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required