Why does C# disallow readonly local variables?

后端 未结 13 1202
萌比男神i
萌比男神i 2020-11-27 17:17

Having a friendly debate with a co-worker about this. We have some thoughts about this, but wondering what the SO crowd thinks about this?

13条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 17:42

    I would like local readonly variables in the same manner as I like local const variables. But it has less priority than other topics.
    Maybe its priority is the same reason for C# designers to not (yet!) implement this feature. But it should be easy (and backward compatible) to support local readonly variables in future versions.

提交回复
热议问题