c#/복습 공부
람다식 연습 3번 (Action)
by 이지훈26
2021. 9. 7.
using System;
using System.Collections.Generic;
namespace Helloworld
{
class App
{
//생성자
public App()
{
//물, 우유, 설탕, 소금, 강력분, 이스트, 버터
string[] ingredient = {"물", "우유", "설탕", "소금", "강력분", "이스트", "버터"};
/*
* Cook메서드가 출력하는거...
* 물, 우유, 설탕, 소금, 강력분, 이스트, 버터
넣고 반죽을 합니다.
오븐에 넣고 기다립니다.
빵이 만들어졌습니다.*/
this.Cook(ingredient, (bread) => {
Console.WriteLine(bread); //Bread (인스턴스)
});
}
private void Cook(string[] ingredient1, Action<Bread> callback)
{
foreach(string name in ingredient1)
{
Console.WriteLine(name +",");
}
Console.WriteLine();
Console.WriteLine("넣고 반죽을 합니다.");
Console.WriteLine("오븐에 넣고 기다립니다.");
Console.WriteLine("빵이 만들어 졌습니다.");
callback(new Bread());
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Helloworld
{
class Bread
{
public Bread()
{
}
}
}