default value for a static property

前端 未结 4 1864
情书的邮戳
情书的邮戳 2021-01-03 17:41

I like c#, but why can I do :

public static bool Initialized { private set; get; }

or this :

public static bool Initialized         


        
4条回答
  •  暖寄归人
    2021-01-03 17:51

    You could use a static constructor

    static MyClass()
    {
        Initialized = false;
    }
    

    However, as has been mentioned by others the default value of a bool will be false.

提交回复
热议问题