반응형
- 코드 예시
using System.Collections.Generic;
public class MyList
{
private List<int> _list = new List<int>();
public void Add(int item) //추가하기
{
_list.Add(item);
}
public void RemoveAt(int index) //index 번째 리스트 제거
{
_list.RemoveAt(index);
}
public int GetAt(int index) //index 번째 리스트 가져오기
{
return _list[index];
}
public int Count //List 길이
{
get { return _list.Count; }
}
}
- 다른 곳에서 사용하기
MyList list = new MyList();
list.Add(5);
list.Add(10);
list.Add(15);
int firstItem = list.GetAt(0);
list.RemoveAt(1);
int count = list.Count;
반응형
'개발 > C#' 카테고리의 다른 글
유니티 C# 반올림, 올림, 내림, 소수점 2자리 버리기 간단 구현 (0) | 2023.02.18 |
---|---|
유니티 C# RectTransform width height 간단 수정법 (0) | 2023.02.17 |
유니티 C# 메모장 간단 구현 Unity NotePad (0) | 2023.01.29 |
유니티 C# 자료구조 스택 Stack 간단 사용법 (0) | 2023.01.29 |
유니티 C# 자료구조 큐 Queue 간단 사용법 (0) | 2023.01.29 |
유니티 C# 플레이어 추적하는 Monster AI 간단 구현 (0) | 2023.01.29 |
유니티 C# 캐릭터 발자국 소리 간단 구현 (0) | 2023.01.29 |
유니티 C# 총알 발사하기 간단 구현 bullet Shot - 슈팅게임 (0) | 2023.01.29 |
댓글