What is the difference between Const and Static in C#?

前端 未结 5 1331
被撕碎了的回忆
被撕碎了的回忆 2020-12-08 10:19

I am eager to know the difference between a const variable and a static variable.

As far as I know a const is also static and can not be accessed on instance variabl

5条回答
  •  心在旅途
    2020-12-08 11:00

    A constant is a variable that cannot be changed in value.

    A static is a variable that cannot be used outside the scope of it's declaration. That is, if it is a global variable then it can only by used in the file that declares it. If it is a variable inside a function, then it can be use only inside that function.

提交回复
热议问题