The best thing you could do is to create a class indeed.
public class Room
{
public string Name { get; set; }
public string Description { get; set; }
}
Then you can create a list of Rooms
List<Room> rooms = new List<Room>();
To add objects
Room room = new Room { Name = "", Description = "" };
rooms.Add(room);
From this point forward I will talk about things that exist, but that are not necessarily the best thing to do.
You can create an extension method such this one
public static class ListRoomExtender
{
public static void Add(this List<Room> rooms, string name, string description)
{
rooms.Add(new Room { Name = name, Description = description });
}
}
As I've specified, this method will only exist for lists of rooms. So if I have
List<Room> rooms = new List<Room>();
I can use
rooms.Add("Room name", "Room description");
Other types of "lists"
StringDictionary
Dictionary<string, string>
- You can't store more information if needed, only a pair of strings.
- You don't have semantics, you access data through properties
Key and Value.
- You can't add two items with the same key.
List<KeyValuePair<string, string>>
- You can't store more information if needed, only a pair of strings.
- You don't have semantics, you access data through properties
Key and Value.