using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study10 { class App { //2. 대리자 형식 정의 delegate void MyDel(string contents); //생성자 public App() { //3. 대리자 변수 정의 //MyDel myDel; //4. 대리자 인스턴스 생성 (메서드 연결), 변수에 할당 //myDel = new MyDel(this.Print); this.LoadFile(null); //대리자 변수에 null값 허용 } private void LoadFile(MyDel myDel) { ..
App 클래스 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study10 { class App { //생성자 public App() { Calculator cal = new Calculator(); int sum = cal.Plus(1, 2); Console.WriteLine("sum: {0}", sum); //(불가능, Minus는 static 메서드) //static 메서드는 형식으로 접근 //int result = cal.Minus(5, 2); int result = Calculator.Minus(5, 2); Consol..
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study10 { class App { //2.대리자정의 : 클래스안에다 한다. //주의사항 : 대리자 인스턴스에 연결한(할당할) 메서드의 시그니처와 동일해야한다. //메서드 정의부터 한 뒤 대리자 생성 delegate int MyDelegate(int a, int b); //생성자 public App() { //3. 변수정의 MyDelegate del; //3. 대리자 인스턴스화 del = new MyDelegate(Plus); //5. 대리자 호출 :대리자의 메서드 호출 int ..
using System; using System.Collections; using System.Collections.Generic; namespace Study10 { class App { //생성자 public App() { //문자형식(Char) 변수 a를 정의 char a; //값을 할당할땐 작은 따옴표로 할당'' a = 'a'; //변수의 값을 출력 Console.WriteLine(a); Console.WriteLine(a++); //65+1 Console.WriteLine(a + 1); Console.WriteLine(a - 1); Console.WriteLine(a--); //문자 형식은 정수로 암시적 변환 가능 int b = (int)a; //명시적 int c = a; //암시적 string..
App단 using System; using System.Collections; using System.Collections.Generic; namespace Study09 { class App { public App() { Marine marine = new Marine(); Firebat firebat = new Firebat(); marine.Attack(); firebat.Attack(); } } } 테란 유닛 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study09 { class TerranUnit { //생성자 p..
using System; using System.Collections; using System.Collections.Generic; namespace Study09 { class App { public App() { //Qeueu인스턴스 생성 Queue q = new Queue(); //Add q.Enqueue(1); q.Enqueue(2); q.Enqueue(3); //contains bool contains = q.Contains(3); Console.WriteLine(contains); //단일 요소 가져오기 int peek = q.Peek(); //확인 Console.WriteLine(peek); int num = q.Dequeue(); //제거 Remove Console.WriteLine(num..
using System; using System.Collections; using System.Collections.Generic; namespace Study09 { class App { public App() { Console.WriteLine("App생성자 입니다."); //list 인스턴스 생성 List armors = new List(); Armor armor0 = new Armor("투구"); Armor armor1 = new Armor("갑옷"); Armor armor2 = new Armor("어깨 방어구"); Armor armor3 = new Armor("무릎 방어구"); //Add armors.Add(armor0); armors.Add(armor1); armors.Add(armor2); ..