반응형
using System.Linq ;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestList : MonoBehaviour {
void Start() {
List<string> fruits = new List<string>() {
"apple",
"orange",
"apple",
"melon"
} ;
List<string> foods = new List<string>() {
"rice",
"apple",
"cookie"
} ;
// List 내부에서 중복 제거
fruits = fruits.Distinct().ToList();
// 2개의 List에서 중복 제거
List<string> FoodsExceptFruits = new List<string>() ;
FoodsExceptFruits = FoodsExceptFruits.Except(fruits).ToList() ;
// index 알아내기
int indexId = fruits.IndexOf("orange") ;
}
}
반응형
'tips > 자주쓰는 C# 스크립트' 카테고리의 다른 글
문자열 String 자주쓰는 함수 (0) | 2021.07.03 |
---|---|
유니티. 스프라이트의 레이어 순서 SortingGroup (0) | 2021.05.04 |
유니티 C# 자주쓰는 딕셔너리 Dictionary<T> 메서드들 (0) | 2021.02.04 |
애드몹 적응형 배너 adaptive banner 적용하는 방법. (0) | 2021.01.23 |
유니티 RectTransform 좌표 이동 (0) | 2020.12.30 |
댓글