CSharp examples for System.Collections.Generic:IList
Add item to IList If Not Exist
using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.Generic; using System;//from ww w.j a va 2 s.com public class Main{ public static void AddIfNotExist<T>(this ICollection<T> collection, T item) { if (!collection.Contains(item)) collection.Add(item); } }