Are immutable arrays possible in .NET?

后端 未结 9 849
忘了有多久
忘了有多久 2020-12-05 23:22

Is it possible to somehow mark a System.Array as immutable. When put behind a public-get/private-set they can\'t be added to, since it requires re-allocation a

9条回答
  •  我在风中等你
    2020-12-05 23:58

    The best you can hope to do is extend an existing collection to build your own. The big issue is that it would have to work differently than every existing collection type because every call would have to return a new collection.

提交回复
热议问题