'●' 카테고리의 글 목록 — 웹툰PD 지망생 : 정민재

    09.Nullable(널러블)

    using System; using System.Collections.Generic; using System.Reflection; namespace Csharp { // Nullable = Null + able -> (Null이라는 타입을 가질 수 있다) class Program { //있냐 없냐를 표현하는 마땅한 방법이 없다. static int Find() { //물론 0을 이용해서 반환해서, 0은 없는 값이라고 규정 할 수도 있겠지만 너무 억지임 return 0; } static void Main(string[] args) { // ?(물음표)를 붙이면 null이 될 수도 있다는 뜻 int? number = null; number = 3; int a = number; //빨간 줄 } } } usin..

    08.reflection 리플렉션

    using System; using System.Collections.Generic; namespace Csharp { class Program { // Reflection : X-Ray // 기능 : class가 가지고 있는 모든 정보들을 runtime(프로그램이 실행되는 도중에) 다 뜯어보고 분석을 할 수 있다. class Monster { public int hp; protected int attack; private float speed; void Attack() { } } static void Main(string[] args) { Monster monster = new Monster(); // C#에서 우리가 만드는 모든 객체들은 다 object 객체에서 파생되어 나오는 것. 그래서 다들 Ge..

    07.Exception(예외처리)

    using System; using System.Collections.Generic; namespace Csharp { class Program { static void Main(string[] args) { int a = 10; int b = 0; int result = a / b; try { // 1. 0으로 나눌 때 // 2. 잘못 된 메모리를 참조 (null) // 3. 너무 많은 용량을 복사 (오버플로우) } catch(Exception e) { } } } } using System; using System.Collections.Generic; namespace Csharp { class Program { static void Main(string[] args) { try { // 1. 0으로 ..

    06.Lambda(람다)

    using System; using System.Collections.Generic; namespace Csharp { // Lambda : 일회용 함수를 만드는데 사용하는 문법. enum ItemType { Weapon, Armor, Amulet, Ring } enum Rarity { Normal, Uncommon, Rare } class Item { //아이템 종류 public ItemType ItemType; //아이템 희귀도 public Rarity Rarity; } class Program { static List _items = new List(); //하드코딩 static Item FindWeapon() { foreach(Item item in _items) { //아이템들 중에서 Weapo..

    05.event(이벤트)

    event(이벤트)는 delegate(델리게이트)의 개선 버전이다. 그러므로 delegate(델리게이트) 코드 부터 보도록 한다. using System; using System.Collections.Generic; namespace Csharp { // delegate(델리게이트) : 함수 자체를 넘겨주는 방식. 형식의 이름을 내 맘대로..! (int float이 아니라 france) class Program { //int France()는 함수가 아니라 형식이다(ex : void나 int처럼) delegate int France(); //이 코드를 4개의 부분으로 자르면, // 1. delegate : 형식은 형식인데, 함수 자체를 인자로 넘겨주는 그런 형식 // 2. 반환 : int // 3. 입력..