Try this
List<int> A = new List<int>() { 1, 2, 3, 4 };
List<int> B = new List<int>() { 11, 22, 33, 44 };
List<int> temp = new List<int>();
Enumerable.Range(0, A.Count)
.ToList()
.ForEach(i => temp.Add(methodA(A[i], B[i])));
Suppose if I modify your existing code as under
List<int> A = new List<int>(){1,2,3,4};
List<int> B = new List<int>(){11,22,33,44};
List<int> temp = new List<int>();
for(int i=0;i<A.Count;i++) temp.Add(methodA(A[i],B[i]));
//Method for some operation
private int methodA(int val1, int val2)
{
return val1 + val2;
}
I will get the output as 12,24,36,48.
Running the one I provided will fetch the same answer.
Hope this helps.
and it is in 3.5 framework.