Μίας και System.Collections.ObjectModel.Collection<Τ> δεν έχει τη μέθοδο AddRange τη πρόσθεσα και παραθέτω το κώδικα:
using System.Collections.Generic;
namespace MyCompany.SystemExtra.CollectionsExtra.ObjectModelExtra
{
/// <summary>
/// Provides the base class for a generic collection.
/// Support AddRange method.
/// </summary>
/// <typeparam name="T">The type of elements in the collection.</typeparam>
public class Collection<T> : System.Collections.ObjectModel.Collection<T>
{
/// <summary>
/// Adds the elements of the specified collection to the end of the Collection.
/// </summary>
/// <param name="elements">The collection whose elements should be added to the end of the Collection.
/// The collection itself cannot be a null reference (Nothing in Visual Basic),
/// but it can contain elements that are a null reference (Nothing in Visual Basic),
/// if type T is a reference type.</param>
public void AddRange(IEnumerable<T> elements) {
if (elements == null) return;
foreach (T element in elements)
Add(element);
}
}
}