Func<a, out b, bool>
, just don't compile, how to declare that i want the second parameter be an out
one?
I want to use it like this:
public class Foo() { public Func<a, out b, bool> DetectMethod; }
Delegates defined within a generic class can use the generic class type parameters in the same way that class methods do.
Use Action Delegate to Pass a Method as a Parameter in C# We can also use the built-in delegate Action to pass a method as a parameter. The correct syntax to use this delegate is as follows. Copy public delegate void Action<in T>(T obj); The built-in delegate Action can have 16 parameters as input.
The out is a keyword in C# which is used for the passing the arguments to methods as a reference type. It is generally used when a method returns multiple values.
Actually, Func is just a simple delegate declared in the .NET Framework. Actually, there are several Func delegates declared there:
delegate TResult Func<TResult>() delegate TResult Func<T, TResult>(T obj) delegate TResult Func<T1, T2, TResult>(T1 obj1, T2 obj2) delegate TResult Func<T1, T2, T3, TResult>(T1 obj1, T2 obj2, T3 obj3) delegate TResult Func<T1, T2, T3, T4, TResult>(T1 obj1, T2 obj2, T3 obj3, T4 obj4) delegate TResult Func<T1, T2, ... , T16, TResult>(T1 obj1, T2 obj2, ..., T16 obj16)
So the only thing you can do is declare your custom delegate:
delegate bool MyFunc<T1, T2>(T1 a, out T2 b)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With