CSharp examples for System.Collections.Generic:IList
Reverse IList with while loop
using System.Collections.ObjectModel; using System.Collections.Generic; using System.Collections; public class Main{ public static void Reverse<T> (IList<T> list) {//from w w w.ja va 2s. c o m int end = list.Count - 1; int index = 0; while (index < end) { T tmp = list [index]; list [index] = list [end]; list [end] = tmp; ++index; --end; } } }