default value for a static property

Posted by Blitzz on Stack Overflow See other posts from Stack Overflow or by Blitzz
Published on 2010-04-07T22:23:00Z Indexed on 2010/04/07 22:33 UTC
Read the original article Hit count: 204

Filed under:
|
|
|
|

I like c#, but why can I do :

public static bool Initialized { private set; get; }

or this :

public static bool Initialized = false;

but not a mix of both in one line ?

I just need to set access level to my variable (private set), and I need it set at false on startup. I wouldn't like to make that boring private _Initialized variable, which would be returned by the getter of the public Initialized var. I like my code to be beautiful. (NB: my variable is static, it can't be initialized in the constructor).

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about static