Adds the range to ObservableCollection - CSharp System.Collections.ObjectModel

CSharp examples for System.Collections.ObjectModel:ObservableCollection

Description

Adds the range to ObservableCollection

Demo Code

// Redistribution and use in source and binary forms, with or without
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System;//w  w w.  j a  va 2s  . c  o m

public class Main{
        /// <summary>
        /// Adds the range.
        /// </summary>
        /// <typeparam name="T">The type of the generic.</typeparam>
        /// <param name="oc">The observable collection.</param>
        /// <param name="collection">The collection to add.</param>
        public static void AddRange<T> ( this ObservableCollection<T> oc, IEnumerable<T> collection )
        {
            if ( collection == null )
            {
                throw new ArgumentNullException ( "collection" );
            }
            foreach ( var item in collection )
            {
                oc.Add ( item );
            }
        }
}

Related Tutorials