Some basics for the default in C #:
When an instance of a class (or structure) is created, all fields are initialized with the appropriate default value.
For reference types, this will be null . For value types, it will be equivalent to 0 . This easily explains, since memory management ensures that the new allocated memory is initialized to 0x0 bytes.
Auto properties hide the generated field, but there is one. Therefore, the same rules apply.
Now, to answer your question , the best way to make sure the values are initialized is to make a constructor with one parameter for each property / property and hide the default constructor without parameters:
public Yourtype(String param1, Int32 param2) { this.Variable1 = param1; this.Variable2 = param2; } private Yourtype() { }
Other alternatives are described in the @Sean and @Alex answers if you need to initialize / check only a subset of properties / fields. But this hides some overhead (one bool for each property / field and some indirectness).
Kryptos
source share