위에 Move를 수정 하세요.
-----------------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Helloworld
{
class App
{
//1.대리자 선언
public delegate void Del(int id);
//생성자
public App()
{
//3. 대리자 인스턴스화 (메서드 연결)
Del del = this.MoveComplete;
SCV scv = new SCV(100);
scv.Move(del);
}
//2.연결할 메서드 정의
void MoveComplete(int id)
{
Console.WriteLine("SCV({0}) move complete", id);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Helloworld
{
class SCV
{
private int id;
public SCV(int id)
{
this.id = id;
}
public void Move(App.Del del)
{
for(int i = 0; i < 10; i++)
{
Console.WriteLine("이동중...");
}
del(this.id);
}
}
}
흐름을 조금 알것도 같다~
'c# > 복습 공부' 카테고리의 다른 글
대리자 응용 복습 (문제 3) (0) | 2021.09.07 |
---|---|
대리자 응용 복습 (문제 2) (0) | 2021.09.06 |
대리자 복습 기본 1,2번 (0) | 2021.09.06 |
2차원 배열 변수 선언 (0) | 2021.09.02 |
배열 왼쪽으로 이동하기 6번 (0) | 2021.09.02 |