Я думаю, что вы хотите:
public static Action<Tuple<T1,T2>> CombineWith<T1,T2>
(this Action<T1> action1, Action<T2> action2)
{
//null-checks here.
return tuple => {
action1(tuple.Item1);
action2(tuple.Item2);
};
}
Использование:
Action<int> a1 = x => Console.Write(x + 1);
Action<string> a2 = x => Console.Write(" " + x + " a week");
var combined = a1.CombineWith(a2);
// output: 8 days a week
combined(Tuple.Create(7, "days"));
РЕДАКТИРОВАТЬ : Кстати, я заметил, что вы упомянули в комментарии, что "индивидуальные аргументы будут еще более предпочтительными". В этом случае вы можете сделать:
public static Action<T1, T2> CombineWith<T1, T2>
(this Action<T1> action1, Action<T2> action2)
{
//null-checks here.
return (x, y) => { action1(x); action2(y); };
}