Why must initialization value of field members be determinable at compile time?

Posted by flockofcode on Stack Overflow See other posts from Stack Overflow or by flockofcode
Published on 2010-06-13T19:14:18Z Indexed on 2010/06/13 19:22 UTC
Read the original article Hit count: 167

Filed under:

1) Why must initialization value of field members be determinable at compile time?

2) But if the initialization value needs to be determined at compile time, then why am I able to initialize a A.b field using a reference to an object:

class A
{
     B b = new B(); 
}

class B {}

Thank you

© Stack Overflow or respective owner

Related posts about c#