© { JSL }
89
Local Variables
·
local variables can be declared
const
w
but not
static,
and not
readonly
w
and
const
is only for
simple
types
w
must be initialized to compile time constant value
struct
GoodExample
{
...
void
Func()
{
const int
answer = 42;
const
Suit trumps = Suit.Club;
}
}
OK
struct
BadExample
{
...
void
Func()
{
const int
lv = F();
static
Pair origin = ...;
readonly
Pair p = ...;
}
}
compile
time
errors