class Program
{
static void Main(string[] args)
{
Say2(GetHello);
Console.ReadLine();
} static string GetHello(string str)
{
return $@"Hello {str}";
}
static void Say2(Func<string, string> func)
{
var hello = func("CSharp");
Console.WriteLine(hello);
}
}
▸ 実行ボタンで結果を表示
Source収録記事
この snippet は記事の「C#でのコールバックとは何?」セクションに登場する。コードの前後の文脈・ハマりどころの解説は記事本文で。
