Find index of a key? Dictionary .NET

后端 未结 3 1566
不思量自难忘°
不思量自难忘° 2021-01-22 03:10

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

3条回答
  •  灰色年华
    2021-01-22 03:38

    Without using a different collection it could be done like this. Though I'm not sure how efficient this is.

    classIndex = classes.ToList().IndexOf(new KeyValuePair(newKey, classes[newKey]));
    

提交回复
热议问题