Is there a way to have a private readonly field in a class that could be assigned a value anywhere in the class, but only once??
That is, I am looking for a private read
You can use a private property that checks to see if it was assigned to and only assign a value if it hasn't been.
int? _writeOnceField; private int? WriteOnce { set { if (!_writeOnceFiled.HasValue) { writeOnceFiled = value; } else { // Throw exception } } }