I have a Dictionary<int, object>
where the int
is a property of obj
. Is there a better data structure for this? I feel like using a property as the key is redundant.
This Dictionary<int, obj>
is a field in a container class that allows for random indexing into the obj
values based on an int
id number. The simplified (no exception handling) indexer in the container class would look like:
obj this[int id]
{
get{ return this.myDictionary[id];}
}
where myDictionary
is the aforementioned Dictionary<int, obj>
holding the objects.
This may be the typical way of quick random access but I wanted to get second opinions.