© { JSL }
17
Text Box: readonly Fields
readonly Fields
Folded Corner:
·readonly instance fields...
ware instance fields that cannot be assigned to
w
compile time errors
class Pair
{
    public Pair(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
    public void Reset()
    {
        x = 0;
        y = 0;
    }
    private readonly int x, y;
}
this declares Pair as
an immutable object