today i have a big problem and a heartache...
I have a problem with Dictionary. I wan't to receipt retrieve a Name of a "room" (it's the system) with and ID, but i have this structure:
class RoomManager
{
public readonly Dictionary<uint, Room> _rooms;
public RoomManager()
{
_rooms = new Dictionary<uint, Room>();
AddRoom(new Room(1, "den.png", "The Den", 1));
AddRoom(new Room(2, "disco.png", "Disco", 1));
AddRoom(new Room(3, "brunch.png", "Brunch", 2));
AddRoom(new Room(4, "disco.png", "Disco 2", 3));
}
public Dictionary<uint, Room> GetRooms()
{
return _rooms;
}
public bool AddRoom(Room room)
{
if (_rooms.ContainsKey(room.ID))
{
return false;
}
_rooms.Add(room.ID, room);
return true;
}
}
And the most important:
class Room
{
public uint ID;
public string Codename;
public string Name;
public int Category;
public Room(uint id, string codename, string name, int category)
{
ID = id;
Codename = codename;
Name = name;
Category = category;
}
}
It's a system with Socket, so with the adding of Room, all is display on a webpage and when i click on it, the website send me the ID and me, i want to display in the Console the name of "Room clicked"!
So in conclusion: How do I retrieve with a function the name of it with his ID?