I want to include _main.saida (along with input) in foreach.... has how to do this?
Yes, just use the method Union
(is in the System.Linq namespace) provided the two collections are of the same type
foreach (var item in _main.entrada.Union(_main.saida))
{
...
}
Full example:
public class MainCollection
{
public int[] entrada;
public int[] saida;
public MainCollection()
{
entrada = new int[] { 1, 2, 3 };
saida = new int[] { 4, 5, 6 };
}
}
public class Program
{
private static MainCollection _main = new MainCollection();
public static void Main()
{
foreach (var item in _main.entrada.Union(_main.saida))
{
Console.WriteLine(item);
}
Console.ReadKey();
return;
}
}
explain better... the
foreach
will go through item by item of a collection, of what you are needing ?– Rovann Linhalis