Jon Jagger
jon@jaggersoft.com
Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specificationpreviousnextprevious at this levelnext at this level 18 Structsprevious at this levelnext at this level 18.3 Class and struct differencesprevious at this levelnext at this level 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.
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS