Imho, this is a very bad idea.
Structs in C# are value-types. C# imposes a number of restrictions to ensure that all fields of a struct are initialized:
- Default constructors are not allowed.
- Constructors must initialize all fields within the struct.
If you do not instantiate a struct through a constructor, then all members are set to the result of calling default()
on the member type. This allows structs to be used in arrays. It also allows what you are doing, but is also the reason for the warning.
Ideally, you should define a constructor and initialize the struct with the constructor.
Edit: To clarify the restriction on the default (parameterless) constructor, you cannot explicitly define one, because the compiler provides one, which it uses to initializes all members.