
https://www.youtube.com/watch?v=GXuKiifDpjE&list=PLO56HZSjrPTB4NxAsEP8HRk6YKBDLbp7m&index=63
using System;
using static System.Console;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace testProject
{
    class Program
    {
        static void GoForward() => WriteLine("직진");
        static void GoLeft() => WriteLine("좌회전");
        static void GoFast() => WriteLine("과속");
        // 대리자, 메서드 시그니처 타입이 중요
        delegate void CarDriver();
        static void Main()
        {
            GoForward(); // [1] 내가 직접 운전
            CarDriver goHome = new CarDriver(GoForward); // [2] 대리 운전
            goHome += GoLeft;
            goHome += GoFast;
            goHome += GoFast;
            goHome -= GoFast;
            goHome.Invoke();
            goHome();
        }
    }
}

using System;
using static System.Console;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace testProject
{
    class Program
    {
        static void GoForward() => WriteLine("직진");
        static void GoLeft() => WriteLine("좌회전");
        static void GoFast() => WriteLine("과속");
        // 익명함수로 만들어서 대입해보기
        // static void GoRight() => WriteLine("우회전");
        // 대리자, 메서드 시그니처 타입이 중요
        delegate void CarDriver();
        static void RunLamda(Action action) => action();
        static void Main()
        {
            //GoForward(); // [1] 내가 직접 운전
            CarDriver goHome = new CarDriver(GoForward); // [2] 대리 운전
            goHome += GoLeft; goHome += GoFast; goHome -= GoFast;
            // 익명 함수
            goHome += delegate () { WriteLine("우회전"); };
            // goHome += delegate { WriteLine("후진"); };
            // 람다식
            goHome += () => WriteLine("후진");
            goHome(); // goHome.Invoke();
            // 내장된 대리자 형식을 통해서 직접 대리자 개체 생성 : Func<T>, Predicate<T>, ...
            Action driver = GoForward;
            driver += GoLeft;
            driver += () => WriteLine("후진");
            driver();
            RunLamda(() => WriteLine("매개 변수로 람다식(함수 이름, 무명 메서드) 전달"));
        }
        
    }
}
