0

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?

5
  • Show some code please. Commented Oct 31, 2016 at 16:12
  • 1
    @Servy that doesn't answer the why IMHO. Commented Oct 31, 2016 at 16:14
  • 1
    @mybirthname Why? The question is valid without code. Commented Oct 31, 2016 at 16:14
  • 2
    A struct is not allowed to have a default constructor. Which is what is needed to get fields initialized. Use a class instead. Commented Oct 31, 2016 at 16:16
  • See this : stackoverflow.com/questions/575901/… Commented Oct 31, 2016 at 16:20

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.