How to get array upperbound value

# How to get array upperbound value

**aksh1yadav**#3

Hey @shakahamed

**Array.GetUpperBound Method (Int32)** - Gets the index of the last element of the specified dimension in the array.

Parameters:

**dimension**

Type: System.Int32

A zero-based dimension of the array whose upper bound needs to be determined.

**Return Value**

Type: System.Int32

The index of the last element of the specified dimension in the array, or -1 if the specified dimension is empty.

**Note:** - GetUpperBound(0) returns the last index in the first dimension of the array, and GetUpperBound(Rank - 1) returns the last index of the last dimension of the array.

Reference: Array UpperBound.xaml (5 KB)

Regards…!!

Aksh

Regards…!!

AKsh

**shakahamed**#4

I am not sure with the end array value. How to get the last array value.

Regards,

Shakeer N

**aksh1yadav**#5

Mate then specify problem with clear words

it is so simple to get last value . just use variable count of int type and assign array length to it-1.

then directly pass array count as an index to array name.

like arr_name(arr_name.length-1) // -1 because array indexing starts from 0 to length

Regards…!!

Aksh

**shakahamed**#6

Thanks for the post Aksh.

I have a Array variable with length of 10.

But all the array will not be occupied.

For example :

i am writing a loop which will store each value in a array variable. Sometimes it will end with 4 array values.

So i want to identify that last value.

Regards,

Shakeer N

**aksh1yadav**#8

So that is what i have mentioned in my first post. even you dont have to pass the length of array by using

Array.GetUpperBound Method (0) you will always get the actual length of array considering 0 as a starting index then use the returned value as your index with particular array to get the value.

Regards…!!

Aksh

**arivu96**#9

Hi @shakahamed ,

use arr_value.length-1 to get the length.

to get last value use -> arr_value(arr_value.length-1)

to get first value use -> arr_value(0)

Regards,

Arivu