I have an interface class Position with get and set methods.
Then I have classes Objects1,Objects2,... that extends interface Position. And in the end I have class Scene which have List with getter and setter for this list. I am saving my Objects1, Objects2 in it.
Then I have a class Level that extends class Scene. There I created Objects1,Objects2,... and add them to the List.
When I get the first item from the List and I want to call that set function to set Position it says “Cannot modify the return value because it is not a variable”. How to solve this?
interface Position
{
public Vector2 PositionCords
{
get; set;
}
}
class Scene
{
private List<Position> _Items;
public Scene()
{
_Items = new List<Position>();
}
public List<Position> SceneItems
{
get => _Items;
set => _Items = value;
}
}
class Objects1 : Position
{
public Vector2 PositionCords
{
get;set;
}
}
class Level: Scene
{
private Scene _scene;
private Objects1 _itemA;
public Level()
{
_scene = new Scene();
_itemA = new Objects1();
_scene.SceneItems.Add(_itemA);
_scene.SceneItems.Add(_itemA);
//error
_scene.SceneItems[0].PositionCords.X = 0;
}
}