C#中如何取得数组中相同元素的个数用最快的方法

2024-12-04 08:08:23
推荐回答(1个)
回答1:

string[] value = new string[] { "DFF11", "DFF11", "RFF11", "RFF11", "RFF11", "CFF11" }; var source = value.GroupBy(t => t.Trim()).Select(t => new { count = t.Count(), key = t.Key }).ToArray(); foreach (var s in source) Console....