Returns the entry in this array at the given index, or null if the index is out of bounds - CSharp System

CSharp examples for System:Array Null Element

Description

Returns the entry in this array at the given index, or null if the index is out of bounds

Demo Code


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

public class Main{
        /// <summary>
      /// Returns the entry in this array at the given index, or null if the index is out of bounds
      /// </summary>
      public static T Get<T>(this T[] arr, uint index)
      {
         if (index >= arr.Length)
         {
            return default(T);
         }
         return arr[index];
      }
}

Related Tutorials