I get the "only auto-implemented properties can have initializers in C#" error when trying to do the following:
public int Precision
{
get { return Precision; }
set
{
if (value < 0)
Precision = 0;
else if (value > 15)
Precision = 15;
else
Precision = value;
}
} = 12;
Why is this not allowed?
thissince auto-initialisation happens before the object is fully constructed, whereas your setter can. Also the setter probably can't run because the object isn't fully instanced either, so what do you want the auto-initialisation to set? If you have no backing field (because your setter doesn't set one) what is it supposed to do? (and also the above, you should have a private backing field which is what an auto-property has behind the scenes)