variable that can't be modified

后端 未结 9 1947
我寻月下人不归
我寻月下人不归 2021-01-04 02:14

Does C# allow a variable that can\'t be modified? It\'s like a const, but instead of having to assign it a value at declaration, the variable does not have any

9条回答
  •  既然无缘
    2021-01-04 03:13

    You can declare a readonly field variable which can be set only in the constructor or directly through its declaration.

提交回复
热议问题