This just for general knowledge:
If I have two, let’s say, List, and I want to iterate both with the same foreach loop, can we do that?
Edit
Just to clarify, I wanted to do this:
List<String> listA = new List<string> { "string", "string" };
List<String> listB = new List<string> { "string", "string" };
for(int i = 0; i < listA.Count; i++)
listB[i] = listA[i];
But with a foreach =)
This is known as a Zip operation and has been supported since .NET 4.
With that, you would be able to write something like:
As an alternative to the anonymous type with the named fields, you can also save on braces by using a Tuple and its static
Tuple.Createhelper: