using foreach loop for two lists in c# for geting lists values -


  list & lt; String & gt; List A = New List & lt; String & gt; {"A1", "A2"}; & Lt; String & gt; ListB = new list & lt; String & gt; {"B1", "B2"}; For (Int i = 0; I & lt; list A. calculation; i ++) {text + = list a [i] + "and" + list [i]; }   

How can I use this foreach loop?

You can use Linq and method:

  list & Lt; String & gt; List A = New List & lt; String & gt; {"A1", "A2"}; & Lt; String & gt; ListB = new list & lt; String & gt; {"B1", "B2"}; Frohack (Various Combinations Zip in list A (listB, (A, B) => New {A = A, B = B})) {text + = pair.A + "and" + pair.B; }    

Comments