CSharp examples for System.Collections:ICollection
Adds a new item to ICollection with the default constructor
using System.Linq; using System.Collections.Generic; using System;/*from w ww .j av a 2 s .c o m*/ public class Main{ /// <summary> /// Adds a new item with the default constructor /// </summary> /// <typeparam name="T"></typeparam> /// <param name="items"></param> /// <returns></returns> public static T AddNew<T>(this ICollection<T> items) where T : new() { var item = new T(); items.Add(item); return item; } }