I am trying to check on which item i have clicked, i am making a kind of inventory, that if you clicked on 1W, that texture will change to the clicked texture. This is the list i have made. But i can't seem to find a code that works.
this.drivers = new List<Driver>()
{
new Driver(this.game, this, new Vector2 (0, 62), "1W", "Images/Clubs/Drivers/1W", this.inventory),
new Driver(this.game, this, new Vector2 (62, 62), "2W", "Images/Clubs/Drivers/2W", this.inventory),
new Driver(this.game, this, new Vector2 (124, 62), "3W", "Images/Clubs/Drivers/3W", this.inventory),
new Driver(this.game, this, new Vector2 (186, 62), "4W", "Images/Clubs/Drivers/4W", this.inventory),
new Driver(this.game, this, new Vector2 (248, 62), "5W", "Images/Clubs/Drivers/5W", this.inventory),
new Driver(this.game, this, new Vector2 (310, 62), "6W", "Images/Clubs/Drivers/6W", this.inventory),
new Driver(this.game, this, new Vector2 (0, 124), "7W", "Images/Clubs/Drivers/7W", this.inventory)
};
I know i can find it to check the name with :
If ( name == "1W")
{
//Do Something
}
but that will mean, if i want to check all 7 i will get 7 if statements, and i have like 3 of this lists, so that will be like 21 if statements.
I know it is possible in 1 sentence per list but i can't remember the code!
I hope someone can help me!