Bon Nourrissage en C#

Une méthode DoSomething qui prend (sans paramètre) et la fonction qu'il gère d'une certaine façon. Est-il un meilleur moyen de créer des "surcharges" pour les fonctions avec des paramètres que l'extrait de code ci-dessous?

public static TResult DoSomething<TResult>(Func<TResult> func)
{
    //call func() and do something else
}

public static TResult DoSomething<T0, TResult>(
    Func<T0, TResult> func,
    T0 arg0)
{
    return DoSomething(() => func(arg0));
}

public static TResult DoSomething<T0, T1, TResult>(
    Func<T0, T1, TResult> func,
    T0 arg0, T1 arg1)
{
    return DoSomething(arg => func(arg, arg1), arg0);
}

public static TResult DoSomething<T0, T1, T2, TResult>(
    Func<T0, T1, T2, TResult> func,
    T0 arg0, T1 arg1, T2 arg2)
{
    return DoSomething(arg => func(arg, arg1, arg2), arg0);
}
InformationsquelleAutor Rauhotz | 2009-01-04