Converts given enumerable to the typed list. - CSharp System

CSharp examples for System:Enum

Description

Converts given enumerable to the typed list.

Demo Code

/********************************************************************
 *  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  ww w  .  j av  a2  s.  c om*/

public class Main{
        //-------------------------------------------------------------------------
    /// <summary>
    /// Converts given enumerable to the typed list.
    /// </summary>
    /// <typeparam name="T">type of list elements</typeparam>
    /// <param name="source">source enumerable</param>
    /// <returns>converted list</returns>
    static public List<T> ToList<T>(IEnumerable source)
    {
      List<T> list = new List<T>();
      foreach (T item in source)
      {
        list.Add(item);
      }
      return list;
    }
}

Related Tutorials