Programming/C#
-
[C#] Enum 변수를 추가 정의하여 사용하는 방법Programming/C# 2021. 7. 6. 23:26
/// /// 상속구조를 통해 정의하는 방법 /// public record InteractType { public static readonly InteractType Interact = new InteractType("Interact"); public override string ToString() { return this.Value; } public InteractType(string value) => this.Value = value; public string Value { get; private set; } } public sealed record InteractTypeDerived : InteractType { public static readonly InteractType Breakable =..
-
[C#] Array, List, Dictionary 컬렉션 정리 겸 복습Programming/C# 2021. 1. 30. 12:41
(94) Array List Dictionary 유용한 함수들 - YouTube 고라니님의 Array, List, Dictionary를 통해 배운 내용을 정리해봤다. Item 클래스 [System.Serializable] public class Item { public int code; public string name; public Item(int code, string name) { this.code = code; this.name = name; } public void Print() { Debug.Log($"code : {code}, name : {name}"); } } Array 선언할 때는 Item을 new로 받은 다음, 대괄호 안에 아이템 객체를 생성함으로써 배열에 삽입을 할 수 있다. [Se..
-
[C#] 확장 메소드(this)Programming/C# 2020. 10. 11. 23:20
확장 메소드 미리 정의된 형식에 원래 형식을 수정하지 않고도 새로운 메소드를 추가시킬 수 있는 기능이다. 정적 클래스에 정적 메소드일 때만 사용이 가능하다. 정적 메소드의 매개변수에 this [형식] [형식 이름] 형태로 기능을 사용할 수 있다. 예시로 기본적인 학생 정보를 담고 있는 클래스를 만들었다. 클래스 안에는 학생에 대한 이름, 학년, 번호를 담고 있다. 그런 정보들을 SetStudent 메소드의 매개변수를 통해서 정보를 지정해 줄 수 있도록 해줬다. public class Student { public string m_strName; public byte m_Grade; public byte m_ID; public void SetStudent(string strName, byte Grade, ..
-
C# 자료형 정리Programming/C# 2020. 2. 17. 14:15
자료형 범위 설명 sbyte -128 ~ 127 부호가 존재하는 8 bit 정수 부호가 있다 아주 작은 값들을 보관하는 용도로 쓰임 byte 0~255 부호가 없는 8 bit short -32,768~32,767 ushort 0~ 65535 int -2147483648~2147483647 uint 0~4294967295 long -9223372036854775808~9223372036854775808 엄청나다 ulong 0~18446744073709551615 더 엄청나다 float +-1.5e-45 ~ +-3.4e38 엄청난데 소수점(실수)자리 값까지 담을 수 있다. double +-5.0e-324~+-1.7e308 크기가 float보다 더 대단하다. 물론 실수값도 담을 수 있다. decimal +-1..