Func<T, TResult> delegate is for a delegate with a single param and return type of TResult.
Is this a special delegate or is it something we can code ourselves manually?
e.g. could I create a Func<T, TResult> but that accepts 2 input params?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
"Func"is actually a family of classes in theSystemnamespace, namely:Func<TResult>(0 params),Func<T,TResult>(1 param),Func<T1,T2,TResult>(2 params) …Func(17)(16 params).There are 17 different “Func” classes total, supporting from 0 to 16 parameters. It is allowable for them to share the name in code (“Func”) even though they are actually different types (
Func,Func',Func'', etc) thanks to how Generics work in .NET — the number of generics determines/disambiguate which actual type is used.Happy coding.
As far as converting between delegates, this may be of use (runs in LINQPad, “C# Program”):