Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

12 lines
875 B
XML

<?xml version="1.0"?>
<clause number="18.3.7" title="Field initializers">
<paragraph>As described in <hyperlink>18.3.4</hyperlink>, 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. <example>[Example: As such, the following example results in one or more compile-time errors: <code_example><![CDATA[
struct Point
{
public int x = 1; // Error, initializer not permitted
public int y = 1; // Error, initializer not permitted
}
]]></code_example>end example]</example> </paragraph>
<paragraph>This restriction applies only to instance fields. Static fields of a struct are permitted to include variable initializers. </paragraph>
</clause>