I would like to create a list of Actions with parameters and then make a foreach in that list and exit executing the methods, each with their respective parameters.
Something more or less with the code below.
private List<Action<int, int>> ListaAction = new List<Action<int, int>>();
private int MetodoExecutar(int numero1, int numero2)
{
return numero1 + numero2;
}
private void MetodoMain()
{
int valor1 = 1;
int valor2 = 2;
ListaAction.Add(MetodoExecutar(valor1, valor2));
}
private void ExecutarListaDeActions()
{
foreach(Action acao in ListaAction)
{
acao();
}
}