N
OTE
N
OTE
lock
is discussed in detail in Chapter 23.
readonly
You can create a read-only field in a class by declaring it as
readonly
. A
readonly
field can
be given a value only by using an initializer when it is declared or by assigning it a value
within a constructor. Once the value has been set, it can’t be changed outside the constructor.
Thus, a
readonly
field is a good way to create a fixed value that has its value set by a
constructor. For example, you might use a
readonly
field to represent an array dimension
that is used frequently throughout a program. Both static and non-static
Do'stlaringiz bilan baham: |