Add First to IList - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IList

Description

Add First to IList

Demo Code

// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;

public class Main{
        public static T[] AddFirst<T>(this IList<T> list, T item)
        {//w  w w .ja  va  2  s  .  com
            T[] res = new T[list.Count + 1];
            res[0] = item;
            list.CopyTo(res, 1);
            return res;
        }
}

Related Tutorials