Information Technology Reference
In-Depth Information
Static Constructors
As with classes, the static constructors of structs create and initialize the static data members,
and cannot reference instance members. Static constructors for structs follow the same rules
as those for classes.
A static constructor is called before the first of either of the following two actions:
￿
A call to an explicitly declared constructor
￿
A reference to a static member of the struct
Summary of Constructors and Finalizers
Table 12-1 summarizes the use of constructors and finalizers with structs.
Table 12-1. Summary of Constructors and Finalizers
Type
Description
Instance constructor
(parameterless)
Cannot be declared in the program. An implicit constructor is sup-
plied by the system for all structs. It cannot be deleted or redefined
by the program.
Instance constructor
(with parameters)
Can be declared in the program.
Static constructor
Can be declared in the program.
Finalizer
Cannot be declared in the program. Finalizers are not allowed.
Search WWH ::




Custom Search