Modifier: readonly
As the name suggests, the readonly modifier is used to make a member readonly. The content of the member can only be set either during the initial declaration (A) or in the constructor for the class that uses the member (B).
Example A:
readonly int foo = 5;
Example B:
class Foo {
readonly int bar;
Foo()
{
bar = 5;
}
}



Leave a comment