Sunday, January 25, 2009

C# Array UBound Function

How to get the Upper Bound of an Array in C#

The upper bound of the array can be retrieved using the Length property as shown below:

private void GetUbound()

{

String[] arTemp = {"First","Second"};

MessageBox.Show (arTemp.Length.ToString ());

}

1 comment:

  1. This is incorrect. The upper bounds of your example is 1. So arTemp.Length - 1.

    ReplyDelete