I am wanting to store key - value data and be able to access it in an efficient manner.
Basically: I have a custom object(EquipmentObj) and w/ in that object is a property called "DeviceType". In the constructor of the object, I am passing a string which goes out to a Dictionary (Local Variable of EquipmentObj) and returns a value if the Dictionary has the key.
In an attempt to minimize initializing the Dictionary 25 times on the heap, (EquipmentObj is instantiated 25-50 times) I am wondering if there is a more efficient way to do this.
My first thought was XML, but I can't add deserialization; I wont get into this.
My next thought was possibly using a static class. But I still need to define the KeyValuePair or Dictionary and static classes cant have instance members.
What would you all suggest?
Here is a sample of what I am basically doing right now.
class EquipmentObj
{
public EquipmentObj(string deviceType)
{
addItems();
this.DeviceType = EquipmentList.ContainsKey(device_Type) ? EquipmentList[deviceType] : "Default";
}
public string DeviceType { get; set; }
private Dictionary<string, string> EquipmentList = new Dictionary<string, string>();
private void addItems()
{
//Add items to Dictionary
}
}