Original Post
Hi there, Take this class I have, the Map class. It has an array of the type Team for the spawnpoints:
public class Map
{
// ...
Room[] teamstart;
public Room[] TeamStart
{
get { return teamstart; }
}
}
Now there is this problem: a returned array is not read only. So the array itself is readonly, but the nodes are not. That means that it's possible to change the contents of the array. Since this is a map, I don't want it. What's the best way to fix this? I see three options: - Use an indexer on the Map class for the teamstarts. However, I already use the indexer for the rooms. - Create a GetSpawnpoint() method. This is inconsistent with the idea of properties and looks kind of weird. - Create a new class like ReadOnlyArray or something like that, that has an indexer. I don't know about this one either... What solution do you suggest? Any other solutions maybe?