using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { List<string> strarr = new List<string>() { "a","a","b","b","c" }; var ss = strarr.FirstOrDefault(a => a == "z"); var s = strarr.GroupBy(a => a).Select(a => new { countsss = a.Count() }).ToList(); //分组 求总 var s3 = strarr.Select(a => new { countsss = a.Count() }).ToList(); // 不分组 就是 当前元素 (a取得就是当前元素) 求总 countsss 全是 1 Console.WriteLine(); Console.WriteLine(); } } }