「C#」引数あり、戻り値ありのFunc型の変数を使用する
書式
Func<データの型,xxx> 変数名 = (引数1,xxx) => {処理コード}
引数あり、戻り値あり
使用例
using System; class Program { static void Main(string[] args) { //int型 引数あり 戻り値あり Func<int, int, int> res = (x, y) => { return x + y; }; Console.WriteLine(res(2, 3)); //double型 引数あり 戻り値あり Func<double, double, double> resB = (x, y) => { return x + y; }; Console.WriteLine(resB(1.2, 3.4)); } }
結果
5
4.6