Removes all empty entries from an array - CSharp System

CSharp examples for System:Array Operation

Description

Removes all empty entries from an array

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from   w w w.j  av a 2s  .c  o  m*/

public class Main{
    /// <summary>
      /// Removes all empty entries from an array
      /// </summary>
      public static T GetWhere<T>(this T[] arr, Func<T, bool> predicate)
      {
         for (var i = 0; i < arr.Length; i++)
         {
            var item = arr[i];
            if (predicate(item))
            {
               return item;
            }
         }
         return default(T);
      }
}

Related Tutorials