-
03/22 델리게이트 연습 2C#/수업내용 2021. 3. 22. 12:01
Program.cs
using System; namespace Study07 { class Program { static void Main(string[] args) { Console.WriteLine("Program"); new App(); } } }
App.cs
using System; namespace Study07 { public class App { //생성자 public App() { Console.WriteLine("App"); Building building = new Building(); //델리게이트 인스턴스화 building.onComplete = this.OnComplete; //빌드 시작 building.Build(); } private void OnComplete() { Console.WriteLine("건설이 완료되었습니다."); } } }
Building.cs
using System; namespace Study07 { public delegate void Del(); public class Building { public Del onComplete; public Building() { } public void Build() { Console.WriteLine("건설이 시작되었습니다."); this.onComplete(); } } }
'C# > 수업내용' 카테고리의 다른 글
03/22 델리게이트 연습 4 (0) 2021.03.22 03/22 델리게이트 연습 3 (0) 2021.03.22 03/22 델리게이트 연습 1 (0) 2021.03.22 03/19 수업내용 메모 (0) 2021.03.19 03/19 1차원 2048게임 구현 (0) 2021.03.19