How to deal with the immutability of returned structs?

前端 未结 6 1894

I\'m writing a game that has a huge 2D array of \"cells\". A cell takes only 3 bytes. I also have a class called CellMap, which contains the 2D array as a private field, and pro

6条回答
  •  星月不相逢
    2021-02-04 17:25

    6 . Use a ref parameter in a method that mutates the value, call it as IncrementCellPopulation(ref cellMap[x, y])

提交回复
热议问题