Why would one ever use the “in” parameter modifier in C#?

后端 未结 5 1960
走了就别回头了
走了就别回头了 2020-12-02 11:08

So, I (think I) understand what the in parameter modifier does. But what it does appears to be quite redundant.

Usually, I\'d think tha

5条回答
  •  醉梦人生
    2020-12-02 11:41

    in it is readonly reference in c# 7.2

    this means you do not pass entire object to function stack similar to ref case you pass only reference to structure

    but attempt to change value of object gives compiler error.

    And yes this will allow you to optimize code performance if you use big structures.

提交回复
热议问题