J'utilise un délégué anonyme dans mon code appelant cet exemple fonction:Utilisation des types de retour de vide avec de nouveaux Func <T, TResult>
public static int TestFunction(int a, int b) {
return a + b;
}
Le délégué ressemble à ceci:
var del = new Func<int, int, int>(TestFunction);
Ma question est: comment spécifiez-vous un type de retour void
pour TResult
? Ce qui suit ne fonctionne pas:
public static void OtherFunction(int a, string b) { ... }
var del = new Func<int, string, void>(OtherFunction);