Hi i have a simple bit of code where i have a private field of a dictionary, and a property that exposes it via get.
But i can still insert to this dictionary from other classes, and was wondering how i can prevent that so i can only insert to the dictionary via the field within the class it is defined and not via the property that exposes it?
This is my field/property code:
private Dictionary<UnitType, Entity> _systems;
public Dictionary<UnitType, Entity> Systems => _systems;
In some other class i am still able to do MyClass.Systems.Add()
which i want to prevent.
Is this possible ?