I am trying to do a foreach loop that runs through 3 lists. Here is what I have currently:
foreach (Button btn in appList && sequenceLsit && FunctionList)
{
if (btn.FillColor != Color.White)
{
// Do stuff
}
}
I tried using tuples, but as I understand, they use a separate variable for each list. I need a single variable (btn) for all 3 lists.
>Solution :
A foreach loop enumerates one list. If you have three separate lists then you need to create one list from them first, which can then be enumerated. The simplest way to do that is the Enumerable.Concat extension method:
foreach (Button btn in appList.Concat(sequenceLsit).Concat(FunctionList))