Converts an instance ICollection to an instance ArrayList. - CSharp System.Collections

CSharp examples for System.Collections:ICollection

Description

Converts an instance ICollection to an instance ArrayList.

Demo Code

// Copyright ? Stateside Technology Limited.  All rights reserved.
using System.Reflection;
using System.Collections;
using System;/*w ww  .j  ava  2  s  . c o  m*/

public class Main{
        /// <summary>
      /// Converts an <see cref="System.Collections.ICollection"/>instance to an <see cref="System.Collections.ArrayList"/> instance.
      /// </summary>
      /// <param name="inputCollection">The <see cref="System.Collections.ICollection"/> instance to be converted.</param>
      /// <returns>An <see cref="System.Collections.ArrayList"/> instance in which its elements are the elements of the <see cref="System.Collections.ICollection"/> instance.</returns>
      /// <exception cref="System.ArgumentNullException">if the <paramref name="inputCollection"/> is null.</exception>
      public static ArrayList ToArrayList(ICollection inputCollection)
      {
         if ( inputCollection == null )
         {
            throw new ArgumentNullException("Collection cannot be null.");
         }
         return new ArrayList(inputCollection);
      }
}

Related Tutorials