CSharp examples for System.Collections.Generic:IList
Return the position of the Minimum in the list.
using System.Collections.Generic; using System.Collections; using System;//from w w w . j a v a 2 s. c om public class Main{ /// <summary> /// Return the postion of the Minimum in the list. /// </summary> /// <param name="list">The list.</param> /// <returns></returns> public static int PosofMinimum(int[] list) { int index = 0; int min = list[0]; for (int i = 1; i < list.Length; i++) { if (list[i] < min) { min = list[i]; index = i; } } return index; } /// <summary> /// Return the postion of the Minimum in the list. /// </summary> /// <param name="list">The list.</param> /// <returns></returns> public static int PosofMinimum(IList<int> list) { int index = 0; int min = list[0]; for (int i = 1; i < list.Count; i++) { if (list[i] < min) { min = list[i]; index = i; } } return index; } }