Pop one element from IList - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IList

Description

Pop one element from IList

Demo Code


using System.Linq;
using System.Collections.Generic;
using System;/*w  w w  . j  a va  2s.c o  m*/

public class Main{
    public static T Pop<T>(this IList<T> list)
    {
      var popped = list.First();
      list.RemoveAt(0);
      return popped;
    }
}

Related Tutorials