foreach with multiple DictionaryEntry

c#, foreach

Solution

The `foreach` keyword cannot do that.

Instead, you can use the LINQ `.Zip()` method:

foreach(var item in rdr0.Zip(rdr1, (d, e)
         => new [] { d.Key.ToString(), d.Value.ToString(), e.Value.ToString() }))

Problem

I am trying to write to a ListView using the contents of 3 three already existing resx files. Using the following loop with only one of the files yields close to what I want but I need is to use the same loop with multiple DictionaryEntrys. What I am trying to do looks like this.. ``` ResXResourceReader rdr0 = new ResXResourceReader(textPath1.Text + ".resx"); ResXResourceReader rdr1 = new ResXResourceReader(textPath1.Text + ".es.resx"); ResXResourceReader rdr2 = new ResXResourceReader(textPath1.Text + ".fr.resx"); foreach ((DictionaryEntry d in rdr0) && (DictionaryEntry e in rdr1)) { string[] row = { d.Key.ToString(), d.Value.ToString(), e.Value.ToString() }; var listViewItem = new ListViewItem(row); listResx.Items.Add(listViewItem); } ```

Original source