CSharp examples for System.Collections.Generic:IList
Maximums the specified list.
using System.Collections.Generic; using System.Collections; using System;/*from ww w. ja v a 2 s. c om*/ public class Main{ /// <summary> /// Maximums the specified list. /// </summary> /// <param name="list">The list.</param> /// <returns></returns> public static int Maximum(IEnumerable<int> list) { int max = int.MinValue; foreach (int num in list) { if (max < num) { max = num; } } return max; } /// <summary> /// Looks for the maximum length of the ArrayList /// </summary> /// <param name="list">list of lists</param> /// <returns>the maximum length</returns> public static int Maximum(ArrayList list) { int max = 0; foreach (ICollection sublist in list) { if (max < sublist.Count) { max = sublist.Count; } } return max; } }