Mega Code Archive

 
Categories / C# / Collections Data Structure
 

Converts an ICollection instance to an ArrayList instance

#region License and Copyright /*  * Dotnet Commons Collections   *   *  * This library is free software; you can redistribute it and/or modify it   * under the terms of the GNU Lesser General Public License as published by   * the Free Software Foundation; either version 2.1 of the License, or   * (at your option) any later version.  *  * This library is distributed in the hope that it will be useful, but   * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY   * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License   * for more details.   *  * You should have received a copy of the GNU Lesser General Public License   * along with this library; if not, write to the   * Free Software Foundation, Inc.,   * 59 Temple Place,   * Suite 330,   * Boston,   * MA 02111-1307   * USA   *   */ #endregion using System; using System.Collections; namespace Dotnet.Commons.Lang {     class MainClass{         /// <summary>         /// Converts an ICollection instance to an ArrayList instance.         /// </summary>         /// <param name="c">The ICollection instance to be converted.</param>         /// <returns>An ArrayList instance in which its elements are the elements of the ICollection instance.</returns>         public static System.Collections.ArrayList ToArrayList(System.Collections.ICollection c)         {             System.Collections.ArrayList tempArrayList = new System.Collections.ArrayList();             System.Collections.IEnumerator tempEnumerator = c.GetEnumerator();             while (tempEnumerator.MoveNext())                 tempArrayList.Add(tempEnumerator.Current);             return tempArrayList;         }    } }