Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- guide
- w3school
- String
- 문제풀이
- 프로그래밍
- Material
- Programming
- 시작해요 언리얼 2022
- python
- Algorithm
- dfs
- 백준
- Basic
- 재귀
- 파이썬
- Unreal Engine 5
- parameter
- DP
- W3Schools
- loop
- UE5
- c++
- Unity
- Class
- dynamic
- github
- 기초
- C#
- Tutorial
- 오류
Archives
- Today
- Total
행복한 개구리
C# 21.03.24.수업내용 본문
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Study004
{
public class App
{
//대리자 선언
public delegate void GoHome();
//대리자 선언
public delegate void Say(string message);
public class Mic
{
public int id;
//생성자
public Mic(int id)
{
this.id = id;
}
public void Speak(string message)
{
if (this.id == 2)
{
string str1 = message.Substring(0, 2);
string str2 = message.Substring(2);
Console.WriteLine("{0}...{1}...", str1, str2);
}
else
{
Console.WriteLine(message);
}
}
}
public App()
{
Mic mic1 = new Mic(1);
Mic mic2 = new Mic(2);
Say say = new Say(mic1.Speak);
say += new Say(mic2.Speak);
say("안녕하세요");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Study004
{
//대리자 선언
public delegate void DelPrint(string message);
public class App
{
public class Printer
{
//생성자
public Printer()
{
}
public void Print(string message)
{
Console.WriteLine(message);
}
}
public App()
{
Console.WriteLine("App");
//대리자 초기화
Printer printer = new Printer();
DelPrint print1 = new DelPrint(printer.Print);
print1("무이야아호오");
DelPrint print2 = delegate (string message)
{
Console.WriteLine("==== 무명메서드 ====");
Console.WriteLine(message);
};
//대리자 호출
print2("무~야~호!");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Study004
{
//대리자 선언
public delegate void DelPrint(string message);
public delegate string DelPrintWithLogo(string logo);
public class App
{
public class Printer
{
//생성자
public Printer()
{
}
public void Print(string message)
{
Console.WriteLine(message);
}
public void PrintWithLogo(string logo)
{
Console.WriteLine(logo);
}
}
public App()
{
Console.WriteLine("App");
//대리자 초기화
Printer printer = new Printer();
DelPrint print1 = new DelPrint(printer.Print);
//대리자 호출
print1("프린트1");
DelPrint print2 = delegate (string message)
{
Console.WriteLine("==== 무명메서드 ====");
Console.WriteLine(message);
};
//대리자 호출
print2("프린트2");
//람다식
DelPrint print3 = (message) =>
{
Console.WriteLine("===== 람다식 =====");
Console.WriteLine(message);
};
//대리자 호출
print3("프린트3");
DelPrint print4 = new DelPrint(printer.PrintWithLogo);
print4(@"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@############################@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##############################@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@####################################@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#########################################@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#########################################@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@###########################################@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@###########################################@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@##################################################@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@#@@@@@@@@@@@######################################################@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@################################################@@##@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@##############################################################@@@@@@@@@@@@@@@@@@
@@########################################################$$$$$#$$$$$$$$$$$$$$#######@@@@@@@@@@@@@@@
@@###$$$$$$$#########=======$$############$$$$$$$$$$$$$$$$=**=$$$$$$$$$#####################@@@@@@@@
@@@@#####@@@@@############################$$$$$$$$$$$$$$$$=***=#############################@@@@@@@@
@@@@@##@@@@@@##################$$$$$$##$$$$$$$$$$$$$#####$=***$#####$#######################@@@@@@@@
@@@@@##@@@########################$$$$$$$$$$$$$$$$$$$$$$$$=***=$$$$$$$$############@@@@@@@@@@@@@@@@@
@@@@@@@@@@#########################$=***=$$$$$====$$$$$$$$$$$==***==$$$$$####@######@#######@@@@@@@@
@@@@@@@@@@@########################$=*!*=$$$$=====$$$$$$$$$$$=*!***==$$$#############@@@@@@@@@@@@@@@
@@@@@@@@@@@##################$$$$$$$=*!**$$$$=====$$$$$$$$$$$$*!***===$###$$$$################@@@@@@
@@@@@@@@@@@##############$$$$$$$$$$$*****=============$$$$$$$==*****===$$$$$$$$$$###############@@@@
@@@@@@@@@@@##############$$$=============****====*!***==$$$=====*********==$##$$#####@@@@@@@####@@@@
@@@@@@@@@@############$$$$=*******=======!!!!****!;;!!**====*******!!!!!!!*=###############@@@@@@@@@
@@@@@@@###############$===*!!;;;;;!!!***!;;;;!!!;:;;;;!******!!!*!!;;!;;;;!=$###########@@@@@@@@@@@@
@@@@@@@###############$=*!;:~~~-~~:;;!!!!;:::;;;:~~~~:;;;;;;;;;;;:~~~~~~~:;*$$##########@@@@@@@@@@@@
@@@@@@@##############$=*!;~-.. ..,~~:;:::~~~::~~~~:::;;;;;!;;;:~-,. ,,-:!=$$#########@@@@@@@@@@@@
@@@@@@#@############$$=!;:, ,~~~:::::~~~~~----~~~~:~:~~---,. ,:;*=$$#################@@@
@@@@###############$$=*;:~. .,.,,,,,,,,.........,,,,,,,,,. . .~;!*=$$##################@
@###############$$$$$*!;:, . ,:;*==$$$$$$$$$$#########@
@@###############$$$==;::. .. ~;!=$$$###$$$###$$$$$$$$@
@@@@#############$$$==;~ .. :!**=======$$$$$$$$$$$$@
@@@@@@@@@@@@@@###$$$=!;. . , , . ,;==$$$$$==$$$#########@
@@@@@@@@@@@#######$$=;! .. . .............. ,.. ,..,... ;!!!**!!!***==$#######@
@@@@@@@#####$$####$$=;- . ... .,, ....,,,,,,,,,,,,.. -~, ,,, ,,...,. -*========$$##@####@@@@
@@@####@@@#######$$=*; .... ,, ..,,,----------,,. ~~ ,--~,,,,-,,. !*==========$###@@@@@@
@@@###$#$$$$======*!;; ....,-....,,-----------,,,..::,---~~~~--,,. :!*****===*=$$##@@@@@@
@@####$$$========*!;;- .,,.,~. ..,,---~~~~~---,,, .;-.-~,~~~~~~,,. -!*==$$$$$==$$###@@@@@
@######@######$$$=*!;. . . ...,,~. ..,,--~~~~---,,. .;,.~:-~:~~~~--- .!*=$#########$##@@@@@
@@#####@######$#$=*!;. . . ..,~. ....,,,,,,,,.. .;,.--,~~~~~-,,,. .!*=$$###########@@@@@
@@@####@########$=*!~. .... .... -~, ~:;,,-~~~~~-~-,, .:*==$$$$########@@@@@
@@@@@@#@#######$$=**, . .. . ,....-~~~~::::::::::::~~~~~~~~~ ,-~~. .,---. . -!*=$$$$#######@@@@@@
@@@@@@@@######$$$=*!, . .. ........-,..,-~~:::;;;;:::~~~- ,~-.,--.--.,-, .. .;**==$$$$#####@@@@@@
@@@@@@@@######$$=*!;,.. .............-~:::;;;;:::~, . . ,..,,.-,,.,.... ,;*==$$#######@@@@@#@
@@@###########$$=*!:...... ....... ........,~~~:::::~:, .. .... .. .,.. .:!*=$#######@@@@@@@@
@@@##$$$$#####$$$*!-....... ...,,... . .. -~~~~~~~-~. . ....,,. ...... -!*=$#######@@@@@@@@
@@@@@#########$$$*!-..... ...,,,--........ ..,~~~~~-~-... ........---,,,....... -!*=$#######@@@@@@@@
@@@@@@@@@@@###=$=!;-..... ..,----,.. ......,..~~~-,-~- .......... ,---,,....,.. ,!*=$#########@@@@@@
#######$$$$$=**=*;:, .......,----,....,....,. ~~~~~~:~ .....,.. ,.,---,,....,.. ,;*=$##########@@@@@
#$#####$$$$=****;:- ....,,------....,.,..,..~~~~~~~- ,........,.--~--,,..,... .:*=$#############@@
@@@@###@@@###$==!:- ...,,-----~-... ...... ,--~~~----. .. ... .------,,,,... ~!==$#############@
@@@@@#######$$$=!;- . .,,------,. . . ----~~---~. ..... .,-----,,,,... -!*=$$$##########@@
@@@@##########$*;;- . .,,------,,. ...,-~:::::::::~..,--,..,,,-~~---,,,... ,;*==$$$$##@@@@@@@@
@@@@##########$*;:- ...,---~-,,-:~-,..,~:;!!!****!!!;:-,...~~:~,,~----,,,... ,:!=$$$$$##@@@@@@@@
@@############=*;:, ...,-----,-:;;;::::;!!********!!!!!;:::!!;:-,-~---,,,,.. ,:!=$$$$###@@@@@@@@
#############$=!:~. ...,,---,.-;!!!!!!!;;!!******!!!!!!!!!!**!;~,,----,,.... .:!=$$#####@@@@@@@@
##########$$$$=!:-. ...,,---.,~!;;;;::::;!!!!!;;;;!*!*********!~,.-~--,,.. . .:!=#######@@@@@@@@
#####$$$$$$$$$=!:-. ...,,-,.,!!*====**!!!!!!!:::;!********==**;,.,~--,,. .~!=#######@@@@@@@@
######$$$$$$$$=*;- ..,,,-..-***====******!!;;;;;!============!- .~--,,. .:!=#########@@@@@@
@@##########$$=*;~. . ..,,,-,..;!===**==*==*****!;;!!=**==*****=$=:. ,--,.. ,:*$##########@@@@@
@@@@##########$=!:. ...,,,. ,**=======*********!!**============**...--,.. ,;*$#########@@@@@@
@@@@@@@@######$=*;- ...,, !*==$$====****!!!!*===============***! ,,,.... -!=$#########@@@@@@
@@@@@@@@@@@####$=!- ..,,. -==$$$$$====***!!!!*=======$======**=*$, ....... ~!$$######@@@@@@@@@
@@@@@@@@@@@#####=*;. ..,, *=$$$$$$$====**!!!!*=================#!=. .. .. ,;*$#####@@@@@@@@@@@
@@@@@@@@@@@#####$=!~ ... *==$$$=========*!!!!*=================$=*; .. .:!$$####@@@@@@@@@@@@
@@@@@@@@@@######$=!!~. . .!===$$$==***=====*****========****===$$*=*!~. ,~;*$#####@####@@@@@@@
@@@@@@@@@@@@@@#=**!!*;~,,.-!$$$$$$$$**!!*=$======*!*****==!!!!=$$$=*!!!*!~---:;!*$$######$$$$##@@@@@
@@@@@@@@@@@@@@#=**!**!!!!*==$$$$$$$=**!!*=$$======**======*!!*=$$$=*!!!===*!!!**=$#####$$$$#$##@@@@@
@@@@@@@@@@@@###==**==****===$$$$$$$=*****=$$======$$$$====****=$$$=****$$$==**==$$###=$##$$$$##@@@@@
@@@@@@@@@@@####$===$$$$$$$$$$$$$$$$$=====$$$$=====$$=$=========$=$======$##$==$$####$*=###$=$#@@@@@@
@@@@@@@@@@####################$$$$$$$$$$$$$=$$$$$=======$$$$$$====$$$$$$$$$$$$######$$$#######@@@@@@
@@@@@@@@@@####$$$####$$$#######$$$$$###$=====$$$$$==$$$$$$$$#$$===$$##$$$####$##@@###@####@@#@@@@@@@
@@@@@@@@@@###$===$$$$====$$$######$$$$$$=***==$$$$$$$$###$$##$$===$#########@###@@@##@@@@@@@@@@@@@@@
@@@@###@@@@###@@@########$##########$$$$$$$$$$=**=$$$$$$$$$$$$$$$$$##################@@@@@@@@@@@@@@@
@@#####$$$$$$$##$$$$$##################$$$$$$$===$$$$$$$$$$$$$$$$$##################@@@@@@@@@@@@@@@@
@################$$$$###################$$####$$$$$$$$$$$$$$$$$#$##################@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@#####################$$$#####$$$$$############################@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@###########################$#################################@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@###############################$$$###############################@@####@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@##@####################$$$$##########################@@###@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@###############################################@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@##############################################@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@###########################################@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##########################################@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##########################################@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@####################################@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@###################################@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@####@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@###@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Study004
{
//대리자 선언
public class RCCar
{
public enum eDirection
{
Forward, Backward, Left, Right
}
public void Move(eDirection dir)
{
Console.WriteLine("{0}로 이동합니다.", dir);
}
}
public class RemoteController
{
public delegate void DelMove(RCCar.eDirection dir);
public RCCar car;
private DelMove delMove;
//생성자
public RemoteController(RCCar car)
{
this.car = car;
}
public void Connect(RCCar car)
{
this.car = car;
this.delMove = new DelMove(this.car.Move);
Console.WriteLine("{0}에 연결되었습니다.", car);
}
public void Control(RCCar.eDirection dir)
{
this.delMove(dir);
}
}
public class App
{
public App()
{
Console.WriteLine("App");
//메서드의 매개변수에 대리자형식 사용하기
RCCar car = new RCCar();
RemoteController controller = new RemoteController(car);
controller.Connect(car); //Connect속에서 delMove를 초기화하고 새롭게 할당
controller.Control(RCCar.eDirection.Forward); //그래서 여기서 Move메서드 값이 나올수있음
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Study004
{
class App
{
public App()
{
Console.WriteLine("App");
this.Print(this.GetLength, "안녕하세요"); //Print(this.GetLength 하는 순간에 Func<string,int> funt = this.GetLength 되기 때문에
//대리자 인스턴스 생성
}
private void Print(Func<string,int> func, string str)
{
//대리자 호출
int result = func(str);
Console.WriteLine(result);
}
private int GetLength(string str) //Func<string,int> func와 구조가 같으니
{
return str.Length;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Study004
{
class App
{
public App()
{
Console.WriteLine("App");
int result = this.Calc(1, 7, (x, y) => 1 + 6); //아래와 동일
Console.WriteLine(result);
int result2 = this.Calc(2, 9, (x, y) => 1 + 2); //실제로 2,9를 더하지 않고 calc식을 설정한 값을 반환
Console.WriteLine(result2);
}
public int Calc(int x, int y, Func<int, int, int> calc)
{
return calc(x, y);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study004
{
class Temperature : IComparable<Temperature> //<>을 이용해 타입을 정해줌
{
protected double m_value = 0.0;
public double Kelvin
{
get
{
return m_value;
}
set
{
if(value < 0)
{
throw new ArgumentException("Temperature cannot be less than absolute zero.");
}
else
{
m_value = value;
}
}
}
public Temperature(double kelvin) //입력된 double값들은 모두 Kelvin메서드에서 처리되어 m_value값으로 나옴.
{
this.Kelvin = kelvin;
}
public int CompareTo(Temperature other) //m_value값으로 비교.
{
if (other == null) return 0;
return m_value.CompareTo(other.m_value);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Study004
{
class App
{
public App()
{
Console.WriteLine("App");
SortedList<Temperature, string> temps = new SortedList<Temperature, string>(); //IComparabl<>의 CompareTO에 따라 입력한 값들을 정렬해준다.
temps.Add(new Temperature(2017.15), "Boiling point of Lead");
temps.Add(new Temperature(0), "Absolute zero");
temps.Add(new Temperature(273.15), "Freezing point of water");
temps.Add(new Temperature(5100.15), "Boiling point of Carbon");
temps.Add(new Temperature(373.15), "Boiling point of water");
temps.Add(new Temperature(600.65), "Melting point of Lead");
foreach (KeyValuePair<Temperature, string> pair in temps)
{
Console.WriteLine("kelvin : {0}, desc : {1}", pair.Key.Kelvin, pair.Value);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Study004
{
class App
{
public App()
{
Console.WriteLine("App");
Drone drone1 = new Drone(1);
Drone drone2 = new Drone(2);
DroneController controller = new DroneController();
drone1.Init(controller);
drone2.Init(controller);
controller.Control(1, Drone.eDirection.Forward);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study004
{
public class Drone
{
public enum eDirection
{
Forward, Backward, Left, Right, Up, Down
}
public int id;
private DroneController controller;
public Drone(int id)
{
this.id = id;
}
public void Init(DroneController controller)
{
this.controller = controller;
this.controller.onMove += OnMoveEventHandler;
}
private void OnMoveEventHandler(object sender, DroneEventArgs e)
{
if(e.id == this.id)
{
this.Move(e.dir);
}
else
{
Console.WriteLine("no signal..., id:{0}", this.id);
}
}
public void Move(eDirection dir)
{
Console.WriteLine("[Move] Id:{0}, Direction:{1}", this.id, dir);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study004
{
public class DroneEventArgs : EventArgs
{
public Drone.eDirection dir { get; private set; }
public int id { get; private set; }
public DroneEventArgs(int id,Drone.eDirection dir)
{
this.id = id;
this.dir = dir;
}
}
public class DroneController
{
public event EventHandler<DroneEventArgs> onMove;
public DroneController()
{
}
public void Control(int id, Drone.eDirection dir)
{
DroneEventArgs args = new DroneEventArgs(id, dir);
this.onMove(this, args);
}
}
}
참고
'C# > 수업내용' 카테고리의 다른 글
C# 21.03.26.수업내용 (0) | 2021.03.26 |
---|---|
C# 21.03.25.수업내용 (0) | 2021.03.25 |
C# 21.03.23.수업내용 (0) | 2021.03.23 |
C# 21.03.22.수업내용 (0) | 2021.03.22 |
C# 21.03.19.수업내용 (0) | 2021.03.19 |