c# - Iteration through SortedList -


sortedlist<string, systemuser> users = new sortedlist<string, systemuser>(); users.add("username1",customobject); users.add("username2",customobject); users.add("username3",customobject); 

what i'm trying search list specific key (i.e. username) , return next item in list. if i'm @ end of list need return item in first position.

not sure how go this, sortedlist doesn't seem expose index property.

i have:

foreach (keyvaluepair<string, systemuser> pair in users) {     if (pair.key == lastallocation)     {         // return item after 1     } } 

any suggestion appreciated!

are looking next item (keyvaluepair), value, or index?

bool returnnextitem = false; foreach (keyvaluepair<string, systemuser> pair in users) {     if (returnnextitem)         return pair.value;     if (pair.key == lastallocation)         returnnextitem = true; } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -