CSharp examples for System:Array Search
Returns list that contains all not null objects from the array.
/******************************************************************** * 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 av a 2s . com*/ public class Main{ //------------------------------------------------------------------------- /// <summary> /// Returns list that contains all not null objects from the array. /// </summary> /// <param name="arr">source array</param> /// <returns>list that contains all not null objects from the array</returns> static public IList<T> ArrayToList<T>(T[] arr) where T : class { List<T> list = new List<T>(); foreach (T obj in arr) { if (obj != null) list.Add(obj); } return list; } }