You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A set of extension and helper methods to complement the ones from System.Linq.Enumerable.
Some of these methods are just shortcuts for common Linq operations (e.g. IsNullOrEmpty), or improvements to
existing Linq methods (e.g. specify default value for FirstOrDefault, specify comparer for Max). Others do more
complex things that have no equivalent in standard Linq (RankBy, DistinctUntilChanged).
Return the item of a sequence that has the min or max value for the specified key.
varwinner=players.MaxBy(p =>p.Score);Console.WriteLine("The winner is {0} with {1} points!",winner.Name,winner.Score);
Unlike the well known approach of sorting the list and taking the first item, this method doesn't need sorting and operates in O(n).
RankBy, DenseRankBy
These methods associate a rank with each item of a collection, based on the specified key. The difference between the two is the same as between the RANK and DENSE_RANK functions in SQL:
RankBy leaves "holes" in the ranks if some items are equal, while DenseRankBy does not.