List<string> list = new List<string> {"a", "a", "b", "b", "c", "c"} //(1) var varNew = new HashSet<string> (list); foreach (string item in varNew) { Debug.Log ("item = " + item); } /* item = a item = b item = c */ //(2) var varNew1 = list.Distinct ().ToList (); foreach (string item in varNew1) { Debug.Log ("item = " + item); } /* item = a item = b item = c */
时间: 2024-10-09 07:45:19