Add two lists in a same Data table using single loop

I have two lists (listOfNames and listOfCodes) and want to put them in a same data table.
I want first first item of listOfNames to be in the first column and listOfCodes to be in second column. I know that I have to loop through them but I can’t figure out how to loop through two of these in parallel and not use nested loop. At first I thought of doing the following
For each name in listOfNames
For each code in listOfCodes
Add To Data Row {name.ToString, code.ToString}

but I know this is going to give me wrong output. Can’t think of any other logic. I Really appreciate the help :slight_smile:

@Maryum_Siddique, I assume length of both list are same. If so you can do something like this:


1 Like