I’d like to implement Action as func and get the error : could not use void in this context.
Please advise
Action<string> someFunc_1 = Console.WriteLine;
someFunc_1("Test");
Func<string, void> someFunc_2 = Console.WriteLine;
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.
Action<T1, T2, ...>is done to replaceFunc<T1, T2, ..., void>.You can’t use
voidin a generic. It’s not a type in C#.Then in your case, use
Action<string>instead ofFunc<string, void>.