CSharp examples for System.Collections.Generic:IList
Return the position of the maximum in the list.
using System.Collections.Generic; using System.Collections; using System;/*from www. j ava 2 s .c o m*/ public class Main{ /// <summary> /// Return the position of the maximum in the list. /// </summary> /// <param name="list">The list.</param> /// <returns></returns> public static int PosofMaximum(IList<int> list) { int index = 0; int max = list[0]; for (int i = 1; i < list.Count; i++) { if (list[i] > max) { max = list[i]; index = i; } } return index; } }