Dictionaries are not sorted, so the Key doesn't have any index really. See my question here: http://stackoverflow.com/questions/4227/
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
foreach(KeyValuePair kvp in yourDict)
If the key is an Int and you want the next, use
var newkey = oldkey+1;
if(yourdict.ContainsKey(newkey)){
var newvalue = yourdict[newkey];
}
If the ints are not sequential, you can use
var upperBound = d.Max(kvp => kvp.Key)+1; // to prevent infinite loops
while(!yourdict.ContainsKey(newkey) && newkey < upperBound) {
newkey++;
}
or, alternatively:
var keys = (from key in yourdict.Keys orderby key select key).ToList();
// keys is now a list of all keys in ascending order