Let's look at this situation:
private Func<int, int> callback;
public SomeClass(Func<int, int> callback)
{
this.callback = callback;
}
Then later we can call that function with
callback(5);
and it would return a number.
Now, what I want is something like the following
private Func<T1, T2> callback;
public SomeClass(Func<T1, T2> callback)
{
this.callback = callback;
}
That delegate would accept a function with a signature like
public T1 SomeFunc<T1, T2>(T2)
and could be called by
callback<int, string>("hello")
which would return an int.
Can this be done in C#?
Func<T1, T2>returnsT2, so your example would take a string and return an int...