CSharp examples for System.Collections.Generic:ICollection
Union two collections
// This program is free software; you can redistribute it and/or modify it using System.Collections.Generic; using System.Collections; public class Main{ /// <summary> /// Union two collections /// </summary> /// <typeparam name="T">collection generic type parameter</typeparam> /// <param name="target">Target collection</param> /// <param name="source">Source collection</param> public static void UnionCollections<T>(ICollection<T> target, IEnumerable<T> source) {/* w ww . j a va 2s . com*/ foreach (T item in source) { if (!target.Contains(item)) target.Add(item); } } }