ECMA-334 C# Language Specification18.3.7: Field initializers |
As described in 18.3.4, the default value of a struct consists of the value that results from setting all value type fields to their default value and all reference type fields to null. For this reason, a struct does not permit instance field declarations to include variable initializers.
end example]
struct Point
{
public int x = 1; // Error, initializer not permitted
public int y = 1; // Error, initializer not permitted
}
This restriction applies only to instance fields. Static fields of a struct are permitted to include variable initializers.