Duplicate:
Why should I initialize all fields in my C # structure using an unnamed constructor?
If in the constructor of such a structure as
internal struct BimonthlyPair { internal int year; internal int month; internal int count; internal BimonthlyPair(int year, int month) { this.year = year; this.month = month; } }
I do not initialize the field (account in this case) I get an error message:
The 'count' field must be fully assigned before control is returned to the subscriber
But if I assign all the fields, including count in this case, with something like
this.year = year; this.month = month; this.count = 0;
the error has disappeared.
I think this is because C # does not initialize the structure fields when someone creates a new structure object. But why? As far as I know, it initializes the variables in some other contexts, so why are the structure different decorations?
eKek0 source share