A simple example:
enum ControlType { Foo }
class A
{
public ControlType ControlType = ControlType.Foo;
}
class B
{
public ControlType? ControlType = ControlType.Foo; // <-- error CS0236: A field initializer cannot reference the non-static field, method, or property 'B.ControlType'
}
Why does A
work, but B
fails to compile?
Is it a bug? If not, where this different behavior is described/specified?
4