Common Type System—Value Construction
Value Construction
Because value types are allocated inline, their default initialization is to zero-out all of their bits without
even calling a constructor. This is extremely efficient, avoiding the need to make essentially a method call for each value instantiation. For this reason, C# prohibits creating parameterless constructors for
structs. This avoids confusion with the statement new YourValueType(), which is actually compiled
into IL that creates a new zeroed out chunk of bits. In C#, you cannot guarantee that value type creation
will go through one of your constructors, although this is not entirely obvious immediately.
|

