CSharp · Console
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication1
{
public class Program
{
public static void Main()
{
var collection = new List<Item>
{
new Item(1),
new Item(2),
new Item(3),
new Item(10),
new Item(3),
new Item(4),
new Item(10),
new Item(2),
new Item(3),
new Item(10)
};
var max = collection.Max(x => x.Prop);
var filteredCollection = collection.Where(x => x.Prop == max);
foreach (var item in filteredCollection)
{
Console.WriteLine(item.Prop);
}
}
}
public class Item
{
public int Prop { get; set; }
public Item(int prop)
{
Prop = prop;
}
}
}