Will the code compile
class ReadOnlyEx { public readonly int myReadOnlyValue = 105; public int MethodA() { myReadOnlyValue++; } //Some other code e.g.Main method() etc.. }
No.
You can change the value through a constructor only.
MethodA() is not the constructor here.