Get Free Index from array - CSharp System

CSharp examples for System:Array Index

Description

Get Free Index from array

Demo Code


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

public class Main{
        public static uint GetFreeIndex<T>(this T[] arr)
      {
         uint i = 0;
         for (; i < arr.Length; i++)
         {
            if (arr[i] == null || arr[i].Equals(default(T)))
            {
               return i;
            }
         }
         return i;
      }
}

Related Tutorials