问题
how can i avoid duplicates from a string (in c#) eg.i have a,a,b,b,c i want to get the answer like a,b,c
回答1:
By using HashSet<string>.
回答2:
You could use a List<> and the Contains method to check for this.
Declare it as
List<string> list = new List<string>();
and check as
if (!list.Contains(stringValue))
list.Add(stringValue);
来源:https://stackoverflow.com/questions/2264469/avoid-duplicates