Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Actionをfuncとして実装し、エラーを取得したい:このコンテキストでvoidを使用できませんでした。お知らせ下さい
Action<string> someFunc_1 = Console.WriteLine; someFunc_1("Test"); Func<string, void> someFunc_2 = Console.WriteLine;
Action<T1, T2, ...>を置き換えるために行われFunc<T1, T2, ..., void>ます。
Action<T1, T2, ...>
Func<T1, T2, ..., void>
voidジェネリックでは使用できません。C#のタイプではありません。
void
次に、あなたの場合、Action<string>の代わりにを使用しますFunc<string, void>。
Action<string>
Func<string, void>
Func<string, bool> someFunc_2 = s => { Console.WriteLine(s); return true; };