Why doesn't C# offer constness akin to C++?

前端 未结 5 1509
悲哀的现实
悲哀的现实 2021-02-07 12:53

References in C# are quite similar to those on C++, except that they are garbage collected.

Why is it then so difficult for the C# compiler to support the following:

5条回答
  •  轮回少年
    2021-02-07 13:07

    I wouldn't be surprised if immutable types were added to a future version of C#. There have already been moves in that direction with C# 3.0.

    Anonymous types, for example, are immutable.

    I think, as a result of extensions designed to embrace parallelism, you will be likely to see immutability pop up more and more.

提交回复
热议问题