static void Main(string[] args) { string[] cities = new string[] { "Delhi" , "Kolkata", "New York" , "London", "Tokyo" , "Washington", "Tokyo" }; HashSet<string> hashSet = new HashSet<string>(cities); foreach (var city in hashSet) { Console.WriteLine(city); } }
结果是去重后的。
标签:city,Tokyo,string,hashSet,c#,HashSet,new From: https://www.cnblogs.com/Insist-Y/p/17308668.html