Why does C# not allow const and static on the same line?

前端 未结 5 708
一个人的身影
一个人的身影 2021-02-02 10:03

Why does C# not allow const and static on the same line? In Java, you must declare a field as \'static\' and \'final\' to act as a constant. Why does C# not let you declare co

5条回答
  •  失恋的感觉
    2021-02-02 10:48

    It is true that a C# const implies static BUT, C# has an equivalent to Java's final keyword in the keyword readonly.

    So, in fact, C# allows a const final, it is static readonly in C#.

提交回复
热议问题