I'm working in C# and with a sorted List<T> of structs. I'm trying to iterate through the List and for each iteration I'd like to access the next member of the list. Is there a way to do this?
List<T>
List
Pseudocode example:
foreach (Member member in List) { Compare(member, member.next); }
You can't. Use a for instead
for(int i=0; i<list.Count-1; i++) Compare(list[i], list[i+1]);
2.1m questions
2.1m answers
60 comments
56.8k users