Const methods in C#

后端 未结 4 638
悲&欢浪女
悲&欢浪女 2021-01-01 08:45

In C++, you can define a constant method like so:

int func_that_does_not_modify_this(int arg) const {}

Placing const at the en

4条回答
  •  死守一世寂寞
    2021-01-01 08:48

    No. There's nothing similar in C#.

    No const & either.

    As Jon points out you can obviously implement a const method, but there's no way beyond documentation to let the caller know that a method is const.

提交回复
热议问题