using System; using System.Linq; public class Test { public static void Main() { // your code goes here string info="桃子*3,李子*2,葡萄*3,李子*3,葡萄*2,桃子*4"; info = string.Join(",", info.Split(',').GroupBy(x => x.Split('*')[0]).Select(x => x.Key + "*" + x.Sum(y => int.Parse(y.Split('*')[1])))); Console.WriteLine(info); } }