collections - how to remove commas from list of string values and get unique values from list -
i have list of string values. want remove duplicates it.
list<string> numbers = form.getvalues(); set<string> hs = new hashset<string>(); hs.addall(numbers ); numbers .clear(); numbers .addall(hs); //number values -> 12342,12342, 23434,23434
i unable unique values after converting set because has comma separated values.
it great know in first line in code. have 1 string values , comma or few strings in number list. in first case have split long string. otherwise work 1 element list ... replace first line with:
list<string> numbers = form.getvalues().split(",");
Comments
Post a Comment