カテゴリー
C

独習C#第3版、P559 ステートメント形式のラムダ

using System;

namespace Chapter01All
{
    delegate int Syukei(int x);
    class DelegateLambdaSample2
    {
        static void Main()
        {
            int a = 10;
            Syukei ans = n =>
            {
                int wa = 0;
                for (int i = 0; i <= n; i++)
                    if (n > 0)
                        wa += i;
                return wa;
            };
            Console.WriteLine(ans(a));
        }
    }
}

先ずは簡単な例から。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

inserted by FC2 system