Create One Element List - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:List

Description

Create One Element List

Demo Code


using System.Collections.Generic;
using System.Collections;
using System;/*from w w w  .  j  av a 2 s .com*/

public class Main{
        public static List<T> CreateOneElementList<T>(T element)
        {
            List<T> ret = new List<T>(1);
            ret.Add(element);
            return ret;
        }
}

Related Tutorials