lambda表达式去除重复数据

 

Enumerable.Distinct<TSource> 方法 (IEnumerable<TSource>)


 List<int> ages = new List<int> { 21, 46, 46, 55, 17, 21, 55, 55 };

            IEnumerable<int> distinctAges = ages.Distinct();

            Console.WriteLine("Distinct ages:");

            foreach (int age in distinctAges)
            {
                Console.WriteLine(age);
            }

你可能感兴趣的:(MVC)