Efficient way of getting the name of an item using it's ID? (Inventory system))

I’m scripting an inventory system, and I have the basics down. I know that an array/list is needed for the player’s inventory and the item IDs. My question is: How do I use the item’s ID and get the name/type of it without using a massive switch statement (if that’s possible). And if I do have to use the switch, how would I make that efficient?

Hey There,

You can store the items in a Dictionary for easy setting and fetching.

//Adding an item
public Dictionary<string,Item> myItems = new Dictionary<string,Item>();

/* Item is a made up base class for all your items */

//Add an item
myItems.Add( "ID_85", aHat );


//Get an item
Item myItem = myItems["ID_85"]  //Returns that hat we added before. 

Regards,