-
03/22 델리게이트 연습 1C#/수업내용 2021. 3. 22. 11:54
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"); Button btn = new Button(); //버튼을 눌렀다면 알려줘 btn.onClick = this.OnClickButton; //유저가 버튼을 눌렀다 btn.Click(); } public void OnClickButton() { //설정 팝업을 연다 Console.WriteLine("팝업창을 연다."); } } }
Button.cs
using System; namespace Study07 { public delegate void Del(); public class Button { public Del onClick; public Button() { } public void Click() { Console.WriteLine("버튼을 클릭했습니다."); this.onClick(); } } }
'C# > 수업내용' 카테고리의 다른 글
03/22 델리게이트 연습 3 (0) 2021.03.22 03/22 델리게이트 연습 2 (0) 2021.03.22 03/19 수업내용 메모 (0) 2021.03.19 03/19 1차원 2048게임 구현 (0) 2021.03.19 03/18 수업내용 메모 (0) 2021.03.19