ECMA-334 C# Language Specification

17.4.2: Readonly fields

When a field-declaration includes a readonly modifier, the fields introduced by the declaration are readonly fields. Direct assignments to readonly fields can only occur as part of that declaration or in an instance constructor or static constructor in the same class. (A readonly field can be assigned to multiple times in these contexts.) Specifically, direct assignments to a readonly field are permitted only in the following contexts:

Attempting to assign to a readonly field or pass it as an out or ref parameter in any other context is a compile-time error.

In This Section: