I have a List of strings like this:
{"100", "101, "101", "102, "103, "103", "104", "104", "105"}
And I need get a new list of strings with only the different values:
开发者_开发知识库{"100","101","102","103","104","105"}
Anyone have a quick way to do this?
You can use the Distinct method:
List<string> distinctList = dupeList.Distinct().ToList();
List<String> strings = new List<string>() { "100", "101", "101", "102", "103", "103", "104", "104", "105" };
var distinctStrings = strings.Distinct().ToList(); 
List<string> dupes = new List<string>(){"100", "101, "101", "102, "103, "103", "104", "104", "105"};
List<string> no_dupes = dupes.Distinct().ToList();
Or you could use a HashSet
var noDupes = new HashSet<string>(dupes).ToList();
Also see Remove Duplicates from a List in C#
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论