Get max value from ICollection - CSharp System.Collections

CSharp examples for System.Collections:ICollection

Description

Get max value from ICollection

Demo Code


using System.Collections;
using System;//from   ww  w  . j av  a 2s  . com

public class Main{
    public static object max(ICollection collection)
      {
         object max = null;
         foreach (IComparable obj in collection)
         {
            if (obj.CompareTo(max) > 0 || max == null)
               max = obj;
         }
         return max;
      }
}

Related Tutorials