I've got the error message said "cannot have instance property or field initializers in structs" and wonder if there is any technical reason for this? Why doesn't a compiler behave like an initialization happens in a constructor?
Asked
Active
Viewed 2,281 times
0
-
Show some code please. – mybirthname Oct 31 '16 at 16:12
-
1@Servy that doesn't answer the *why* IMHO. – Patrick Hofman Oct 31 '16 at 16:14
-
1@mybirthname Why? The question is valid without code. – Patrick Hofman Oct 31 '16 at 16:14
-
2A struct is not allowed to have a default constructor. Which is what is needed to get fields initialized. Use a class instead. – Hans Passant Oct 31 '16 at 16:16
-
See this : http://stackoverflow.com/questions/575901/why-struct-can-not-have-parameterless-constructor – PaulF Oct 31 '16 at 16:20