1번 문제
using System;
using System.Collections.Generic;
namespace Helloworld
{
class App
{
//생성자
public App()
{
this.CreateItem((Item item) =>
{
Console.WriteLine("=> {0}", item.name);
});
}
private void CreateItem(Action<Item> callback)
{
callback(new Item("장검"));
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Helloworld
{
class Item
{
public string name;
public Item(string name)
{
this.name = name;
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------
'c# > 복습 공부' 카테고리의 다른 글
람다식 연습 3번 (Action) (0) | 2021.09.07 |
---|---|
람다식 연습 2번(Action) (0) | 2021.09.07 |
대리자 응용 복습 (문제 4) (0) | 2021.09.07 |
대리자 응용 복습 (문제 3) (0) | 2021.09.07 |
대리자 응용 복습 (문제 2) (0) | 2021.09.06 |