CSharp examples for System:Array Index
Returns arr[index] or, if index is out of bounds, arr.Last()
using System.Text; using System.Linq; using System.Collections.Generic; using System;/* w ww .jav a 2 s . c o m*/ public class Main{ /// <summary> /// Returns arr[index] or, if index is out of bounds, arr.Last() /// </summary> public static T GetMax<T>(this T[] arr, uint index) { if (index >= arr.Length) { index = (uint) (arr.Length - 1); } return arr[index]; } }