CSharp examples for System.Collections.Generic:IEnumerable
Min Element from IEnumerable
using System.Linq; using System.Collections.Generic; using System;/*ww w .java 2 s .c o m*/ public class Main{ public static T MinElement<T>(this IEnumerable<T> enumerable, Func<T, int> selector) { var minRank = int.MaxValue; var minElement = default(T); foreach (var element in enumerable) { var rank = selector(element); if (rank < minRank) { minRank = rank; minElement = element; } } return minElement; } }