Will the code compile
class ReadOnlyEx { public static readonly int staticReadOnlyValue; static ReadOnlyEx() { staticReadOnlyValue = 25; } //Some other code e.g. Main Method() etc.. }
Yes.
We can assign a value to a readonly field during the declaration or through a constructor.