how to iterate 3 arrays at once

Unsegedehunse

New Member
I have 3 arrays containing different information. 1 array contains a bunch of id's, the second array contains a bunch of dates and the third contains a bunch of names.I know this is a simple question but I cannot remember how to do it so I apologize for the stupidity.The 3 arrays look like this:\[code\]string[] eventIDs = EventID.Split(','); string[] eventDates = eventCopyDate.Split(','); string[] invNames = investigatorNames.Split(',');\[/code\]the values look like "john Doe,Mark Doe, Tim Doe" hence why the .SplitI've tried a nested for loop here but no success.\[code\]foreach (var id in eventIDs) { foreach (var date in eventDates) { foreach (var name in invNames) { cmd.Parameters.Add(new SqlParameter("@EventID", SqlDbType.Int)); cmd.Parameters["@EventID"].Value = http://stackoverflow.com/questions/12820230/int.Parse(id); cmd.Parameters.Add(new SqlParameter("@InvestigatorName", SqlDbType.NVarChar)); cmd.Parameters["@InvestigatorName"].Value = http://stackoverflow.com/questions/12820230/name; cmd.Parameters.Add(new SqlParameter("@CopyDate", SqlDbType.DateTime)); cmd.Parameters["@CopyDate"].Value = http://stackoverflow.com/questions/12820230/Convert.ToDateTime(date); }//end name foreach }//end date foreach }//end id foreach\[/code\]I know that this will just iterate them through an entire array first before going back to the second nested array. I am trying to iterate to the first value in the array, assign them to the variables then go through the second iteration.So that arrayNames:"john Doe, Mark Doe" arrayDates"12/12/12, 10/12/12" and arrayID:"234,235,236" would be used like:\[code\]"john Doe" "12/12/12" "234""Mark Doe" "10/12/12" "235"\[/code\]
 
Back
Top