CSharp · Console
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication1
{
public class Program
{
public static void Main()
{
var rnd = new Random();
var collection = Enumerable
.Range(1, 100)
.Select(_ => new Item(rnd.Next(30)))
.ToList();
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;
}
}
}