-
03/22 델리게이트 연습 3C#/수업내용 2021. 3. 22. 12:11
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"); FileManager fm = new FileManager(); fm.onOpenComple = this.OnOpenComplete; fm.Open("C:\\test.txt"); } private void OnOpenComplete() { Console.WriteLine("파일 열기 완료"); } } }
FileManager.cs
using System; namespace Study07 { public delegate void Del(); public class FileManager { public Del onOpenComple; public FileManager() { } public void Open(string filePath) { if(onOpenComple != null) { Console.WriteLine("{0}경로의 파일 열기", filePath); this.onOpenComple(); } } } }
'C# > 수업내용' 카테고리의 다른 글
03/22 델리게이트 연습 5 (0) 2021.03.22 03/22 델리게이트 연습 4 (0) 2021.03.22 03/22 델리게이트 연습 2 (0) 2021.03.22 03/22 델리게이트 연습 1 (0) 2021.03.22 03/19 수업내용 메모 (0) 2021.03.19