using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HelloWorld
{
class App
{
//생성자
public App()
{
string[] ingredient = { "물", "우유", "설탕", "소금", "강력분", "이스트", "버터" };
this.Cook(ingredient, (bread) =>
{
Console.WriteLine(bread); //Bread (인스턴스)
});
/*
* Cook메서드가 출력하는거...
* 물, 우유, 설탕, 소금, 강력분, 이스트, 버터
* 넣고 반죽을 합니다.
* 오븐에 넣고 기다립니다.
* 빵이 만들어졌습니다.*/
}
void Cook(string[] arr, Action<Bread> action)
{
Console.Write("재료: ");
foreach (string ele in arr)
{
Console.Write("{0} ", ele);
}
Console.WriteLine();
Console.WriteLine("넣고 반죽을 합니다.");
Console.WriteLine("오븐에 넣고 기다립니다.");
Console.WriteLine("빵이 만들어졌습니다.");
action(new Bread());
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HelloWorld
{
class Bread
{
//생성자
public Bread()
{
}
}
}
'C# > 수업 내용' 카테고리의 다른 글
람다식 연습 5 (Func) 두 수 더하기 (0) | 2021.12.24 |
---|---|
람다식 연습 4 (Func) 장검 (0) | 2021.12.24 |
람다식 연습2 (Action) (0) | 2021.12.24 |
대리자연습8 (0) | 2021.12.24 |
대리자연습6 고블린 (오류수정) (0) | 2021.12.24 |