fields can not access other fields because their value is unknown unless static (they use a default initializer), they simply can't be resolved at compile time.
static fields can however, since they're resolved statically before the containing type is constructed.
Field:
Property:Code:public MyClass() { mIsInitialized = true; // this is usually the preferred initialization pattern for instanced fields. } private bool mIsInitialized;
Code:public bool IsInitialized { get { return mIsInitialized; } set { mIsInitialized = value; } } public MyClass() { mIsInitialized = true; } private bool mIsInitialized;




Reply With Quote