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?
-
Show some code please.mybirthname– mybirthname2016-10-31 16:12:06 +00:00Commented Oct 31, 2016 at 16:12
-
1@Servy that doesn't answer the why IMHO.Patrick Hofman– Patrick Hofman2016-10-31 16:14:05 +00:00Commented Oct 31, 2016 at 16:14
-
1@mybirthname Why? The question is valid without code.Patrick Hofman– Patrick Hofman2016-10-31 16:14:15 +00:00Commented Oct 31, 2016 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– Hans Passant2016-10-31 16:16:27 +00:00Commented Oct 31, 2016 at 16:16
-
See this : stackoverflow.com/questions/575901/…PaulF– PaulF2016-10-31 16:20:52 +00:00Commented Oct 31, 2016 at 16:20
Add a comment
|