using System; using System.Collections.Generic; using System.Diagnostics; using System.Windows.Forms; namespace WindowsFormsApplication4 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { var arr = new[] { new {Val1="1",Val2="B"}, new {Val1="5",Val2="B"}, new {Val1="3",Val2="B"}, new {Val1="2",Val2="B"}, new {Val1="4",Val2="B"} }; var max = arr.Max(t => t.Val1, t => t); Debug.WriteLine(max.Val1 + " " + max.Val2); } } public static class こんなMAX欲しかった { public static TResult Max(this IEnumerable source, Func selecter, Func resultSelecter) where TValue : IComparable, IComparable { TValue maxVal = default(TValue); TResult result = default(TResult); foreach (var item in source) { var val = selecter(item); if (val.CompareTo(maxVal) >= 0) { maxVal = val; result = resultSelecter(item); } } return result; } } }