Swap value in IList - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IList

Description

Swap value in IList

Demo Code


using System.Collections.Generic;
using System;/*from  w  ww  .  j  a v a 2  s  . c om*/

public class Main{
        public static void Swap<T>(IList<T> array, int firstIndex, int secondIndex) where T: struct
        {
            T temp = array[firstIndex];
            array[firstIndex] = array[secondIndex];
            array[secondIndex] = temp;
        }
}

Related Tutorials