2016年7月7日木曜日

デリゲート書き方いろいろ

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DefinedDelegate
{
    class Program
    {

        ////その1
        //private static void Disp() {
        //    Console.WriteLine("Disp()");

        //}

        ////定義済みdelegate
        //private static void a(Action call) {
        //    call();
        //}

        //static void Main(string[] args)
        //{

        //    a(Disp);
        //    Console.ReadLine();
        //}


        ////その2
        //private static void Disp()
        //{
        //    Console.WriteLine("Disp()");

        //}
        //static void Main(string[] args) {
        //    Action act = Disp;
        //    act();
        //    Console.ReadLine();

        //}


            //その3
        static void Main(string[] args) {
            //デリゲートactに代入
            Action act = () => { Console.WriteLine("Hello lamda Expression"); };
            //act実行
            act();

        }
    }
}

0 件のコメント:

コメントを投稿