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

namespace Ramda
{
    internal class Program
    {
        static void Main(string[] args)
        {
            new App();
        }
    }
}

 

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

namespace Ramda
{
    public class App
    {
        //생성자
        public App() 
        {
            Console.WriteLine("App 생성자 실행");

            Hero hero = new Hero();

            hero.Move(() =>
            {
                Console.WriteLine("히어로 이동 완료");
            });

            hero.onDie = () => {
                Console.WriteLine("히어로 죽었다.");
            };
            hero.Die();
        }
    }
}

 

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

namespace Ramda
{
    public  class Hero
    {
        //맴버 변수
        public Action onDie;


        //생성자
        public Hero()
        {
            Console.WriteLine("Hero 생성자 실행");
        }

        public void Move(Action callback) //
        {
            Console.WriteLine("히어로 이동 중...");
            Console.WriteLine("히어로 이동 중...");
            Console.WriteLine("히어로 이동 중...");
            callback();
        }

        public void Die()
        { 
            Console.WriteLine("히어로 죽겠는대?");
            onDie();
        }
    }
}

+ Recent posts