字符串数组去重 比较
有一个字符串 string a="123,123,12,124,125,124,"
怎么去掉重复的123和124然后重新得到一个字符串:string b="123,12,124,125,"
帮忙了 用 C#就好。
[解决办法]
以逗号split,然后循环添加到List,天津前判断是否已经存在
[解决办法]
string a = "123,123,12,124,125,124,"; string[] result = a.Split(',').Distinct().ToArray(); string b = string.Join(",", result);//结果b等于:123,12,124,125,
[解决办法]
string str="123,123,12,124,125,124,"; Regex reg = new Regex(@"((\d+,).*?)\2"); while (str != (str = reg.Replace(str, "$1"))) ; Console.WriteLine(str);
[解决办法]