I am currently in the middle of trying to create a simple rpg C# game and I am stuck fairly early on in the map creation section.
I created a class for my locations:
public class Location
{
private int ID;
private string Name;
public Location(int id, string name)
{
ID = id;
Name = name;
}
}
And I also created a method which fills a list with my locations. Outside in the main program area I created the list so it is accesible by everything:
List<Location> map = new List<Location>();
public void CreateMap()
{
Location start = new Location(1, "START");
Location forest = new Location(2, "FOREST");
Location city = new Location(3, "CITY");
map.Add(start);
map.Add(forest);
map.Add(city);
}
CreateMap();
However, I am stuck now, because I do not know how to access the parameters of my Location objects inside the list, as I only found how to access a string from a list on the internet, or very complicated and confusing answers that I did not at all understand. I wanted to somehow use a static class as I learned that they are usefull when we do not want to access the information inside the class, but I reckon I didn't quite grasp their concept.
tl;dr:I want to take my ID/Name of a specific object out of my list, but I do not know how.