How to iterate through two IEnumerables simultaneously?
- by Danvil
I have to enumerables IEnumerable<A> list1 and IEnumerable<B> list2 and would like to iterate through them simultaneously like:
foreach((a, b) in (list1, list2)) {
// use a and b
}
If they do not contain the same number of elements, an exception should be thrown.
What is the best way to do this?