string a = "123,123,12,124,125,124,";
string[] result = a.Split(',').Distinct().ToArray();
string b = string.Join(",", result);
//结果b等于:123,12,124,125,
------解决方案--------------------
C# code
string str="123,123,12,124,125,124,";
Regex reg = new Regex(@"((\d+,).*?)\2");
while (str != (str = reg.Replace(str, "$1"))) ;
Console.WriteLine(str);
------解决方案--------------------
------解决方案-------------------- string a = "123,123,12,124,125,124,"; string[] str = a.Split(',');
IEnumerable<string> ling = (from b in str select b).Distinct(); StringBuilder strbuil = new StringBuilder(100); foreach (string s in ling) { strbuil.Append(s); }