Can parameters be constant?

后端 未结 9 1530
终归单人心
终归单人心 2020-12-24 04:39

I\'m looking for the C# equivalent of Java\'s final. Does it exist?

Does C# have anything like the following:

public Fo         


        
9条回答
  •  半阙折子戏
    2020-12-24 05:10

    The answer: C# doesn't have the const functionality like C++.

    I agree with Bennett Dill.

    The const keyword is very useful. In the example, you used an int and people don't get your point. But, why if you parameter is an user huge and complex object that can't be changed inside that function? That's the use of const keyword: parameter can't change inside that method because [whatever reason here] that doesn't matters for that method. Const keyword is very powerful and I really miss it in C#.

提交回复
热议问题