Copy IEnumerable to ICollection - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IEnumerable

Description

Copy IEnumerable to ICollection

Demo Code


using System.Collections.Generic;
using System.Collections;
using System;//  w w w .  java 2  s  .c  om

public class Main{
    public static void Copy<T>(IEnumerable<T> source, ICollection<T> target)
    {
      foreach (T item in source)
      {
        target.Add(item);
      }
    }
}

Related Tutorials