[Solved] Go back to second foreach loop


You can use break. It breaks the loop you are in right now.

Plus, in your condition you should use else if rather than multiple if.

foreach (var pair in firstStrings)
{
    foreach (var pair2 in secondStrings)
    {
        if (secondStrings.ContainsKey(pair.Key))
        {
            LogMessage(
                pair.Value + " <----------> " + pair2.Value + " On Line " + (int)(pair.Key.Item1 + 1));

            break;
        }
        else if (!(secondStrings.ContainsKey(pair.Key)))
        {
            LogMessage(
                pair.Value + "Missing data " + " on line " + (int)(pair.Key.Item1 + 1) + " in file " + " " +
                Path.GetFileName(pathTwo));

            break;
        }
        else if (!(firstStrings.ContainsKey(pair2.Key)))
        {
            LogMessage(
                pair2.Value + "Missing data " + " on line " + (int)(pair2.Key.Item1 + 1) + " in file " + " " +
                Path.GetFileName(pathOne));

            break;
        }
    }
}

1

solved Go back to second foreach loop