I am considering using OrderedDictionary. As a key, I want to use a long value (id), and the value will be a custom object.
I use OrderedDictionary because I want to get the object by this identifier, and I want to get the object by its collection index.
I want to use OrderedDictionary as follows:
public void AddObject(MyObject obj)
{
_dict.Add(obj.Id, obj);
}
Somewhere in my code, I have something like this:
public MyObject GetNextObject()
{
_currentIndex++;
return _dict[_currentIndex] as MyObject;
}
Now my question. In the last method, I used an index. Imagine _currentIndex is set to 10, but I also have an object with an id of 10. I set Id as the key.
The identifier for MyObject is of type long. This is not true?
source
share