Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

C# does not allow structs to have initializers, the reason why has been debated before, see here: ( Why can't I initialize my fields in my structs?Why can't I initialize my fields in my structs? )

Simply remove the = false part from your field declarations.

Note that Boolean fields are false by default, making your assignment completely unnecessary.

If you absolutely need fields to have initialized to non-default values then you can still define an additional constructor that sets those values, however it cannot be the default (parameterless) constructor. One alternative option then, is to use a static factory method.

C# does not allow structs to have initializers, the reason why has been debated before, see here: ( Why can't I initialize my fields in my structs? )

Simply remove the = false part from your field declarations.

Note that Boolean fields are false by default, making your assignment completely unnecessary.

If you absolutely need fields to have initialized to non-default values then you can still define an additional constructor that sets those values, however it cannot be the default (parameterless) constructor. One alternative option then, is to use a static factory method.

C# does not allow structs to have initializers, the reason why has been debated before, see here: ( Why can't I initialize my fields in my structs? )

Simply remove the = false part from your field declarations.

Note that Boolean fields are false by default, making your assignment completely unnecessary.

If you absolutely need fields to have initialized to non-default values then you can still define an additional constructor that sets those values, however it cannot be the default (parameterless) constructor. One alternative option then, is to use a static factory method.

Source Link
Dai
  • 157.6k
  • 31
  • 314
  • 436

C# does not allow structs to have initializers, the reason why has been debated before, see here: ( Why can't I initialize my fields in my structs? )

Simply remove the = false part from your field declarations.

Note that Boolean fields are false by default, making your assignment completely unnecessary.

If you absolutely need fields to have initialized to non-default values then you can still define an additional constructor that sets those values, however it cannot be the default (parameterless) constructor. One alternative option then, is to use a static factory method.