CSharp examples for System.Collections.Generic:IList
Adds a range of items into the given list.
/******************************************************************** * FulcrumWeb RAD Framework - Fulcrum of your business * * Copyright (c) 2002-2010 FulcrumWeb, ALL RIGHTS RESERVED * * * * THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED * * FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE * * COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE * * AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT * * AND PERMISSION FROM FULCRUMWEB. CONSULT THE END USER LICENSE * * AGREEMENT FOR INFORMATION ON ADDITIONAL RESTRICTIONS. * ********************************************************************/ using System.Collections.Specialized; using System.Collections.Generic; using System.Collections; using System;//from w w w. j a va2s . com public class Main{ //------------------------------------------------------------------------- /// <summary> /// Adds a range of items into the given list. /// </summary> /// <typeparam name="T">type of elements</typeparam> /// <param name="list">destination list</param> /// <param name="sourceList">source list</param> static public void AddRange(IList list, IEnumerable sourceList) { foreach (object element in sourceList) { list.Add(element); } } //------------------------------------------------------------------------- /// <summary> /// Adds a range of items into the given list. /// </summary> /// <typeparam name="T">type of elements</typeparam> /// <param name="list">destination list</param> /// <param name="sourceList">source list</param> static public void AddRange<T>(IList<T> list, IEnumerable<T> sourceList) { foreach (T element in sourceList) { list.Add(element); } } }