I need to do currentKey+1. So i would like to find the index of the key value and get the next key (or first if at end). How do i find the current index of the key?
I am using a Dictionary<int, classname> and i looked for .Find or IndexOf with Linq to no avail.
Dictionaries are not sorted, so the Key doesn’t have any index really. See my question here: Accessing a Dictionary.Keys Key through a numeric index
Use an OrderedDictionary which has an indexer that takes an Int.
Edit: ‘m not really sure I understand what you want. If you want to iterate through a Dictionary, just use
If the key is an Int and you want the next, use
If the ints are not sequential, you can use
or, alternatively: