KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to get the next element in a list and if the list is at it's end I want the first element. So I just want it to circle in other words. List<int> agents = taskdal.GetOfficeAgents(Branches.aarhusBranch); if (lastAgentIDAarhus != -1) { int index = agents.IndexOf(lastAgentIDAarhus); if (agents.Count > index + 1) { lastAgentIDAarhus = agents[index + 1]; } else { lastAgentIDAarhus = agents[0]; } } else { lastAgentIDAarhus = agents[0]; } I am fairly displeased with my own solution shown above, let me know if you have a better one :)
Tags (comma-separated)
Save Edits
Cancel