본문 바로가기
소프트웨어 개발/유니티(Unity)

[Unity] 리스트 관련 함수

by Sakriun_to 2021. 10. 14.
728x90

1. 추가하기(add)

public List<String> ListString;

ListString.add("추가할 문자열");

 

2. 제거하기(Remove, RemoveAt, RemoveRange)

public List<String> ListString;

ListString.Remove("삭제 할 문자열"); // 값을 가지고 있는 것 찾아서 삭제

ListString.RemoveAt(0); // 인덱스 값으로 삭제

ListString.RemoveRange(index, count); // index부터 Count의 수 만큼 삭제
ListString.RemoveRange(0,3); // 0부터 3개 삭제

 

3. 초기화하기()

public List<String> ListString;

ListString.add("추가할 문자열");

 

4. 문자열 찾기(Contains)

public List<String> ListString;

ListString.Contains("확인할 문자열"); // true, false 반환

 

5. 문자열에 인덱스 번호 출력(IndexOf)

public List<String> ListString;

Debug.Log(ListString.IndexOf("인텍스 번호 출력할 문자열")); // 1 출력 (없으면 -1 출력)
728x90
반응형

댓글