© { JSL }
87
Text Box: const Fields
const Fields
·const fields are implicitly static
wonly simple types, enums, & string can be const
wconst fields require a variable initialiser
wmust be initialized to compile time constant value
struct Pair
{
    private const int x = 0, y = 0;
}
struct BadFields
{
... BadFields(...)
    {
        question = 9 * 6;
    }
... static const int answer = 42;
... const int question;
... const Pair origin = new Pair();
}
OK
compile time errors
this declares Pair with no instance fields
...
implicitly static
...
can't initialize here
...
not initialized
...
Pair not simple type