
18 Structs
18.3 Class and struct differences
18.3.7 Field initializers
Paragraph 11 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. 2 For this reason, a struct does not permit instance field declarations to include variable initializers. [Example: As such, the following example results in one or more compile-time errors:
struct Point
{
public int x = 1; // Error, initializer not permitted
public int y = 1; // Error, initializer not permitted
}
end example]
Paragraph 21 This restriction applies only to instance fields. 2 Static fields of a struct are permitted to include variable initializers.
| |
| Jagger Software Ltd | |
| Company # 4070126 | |
| VAT # 762 5213 42 |