C#
-
[UNITY] 유니티에서 Image Download 하기Programming/Unity 2021. 12. 16. 19:00
WebClient 클래스의 DownloadFile 기반 함수를 통해 다운이 받아진다. 첫번 째 인자 : 다운받을 링크 주소 두번 째 인자 : 다운받은 파일을 위치시킬 파일 경로 using System; using System.Net; void DownLoadFile(Uri uri, string path, Action onCompleted = null) { WebClient client = new WebClient(); client.DownloadFileAsync(uri, path); client.DownloadFileCompleted += (s, e) => onCompleted?.Invoke(e); }
-
[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, ..