<div class="meta" robots="noindex">

</div>

Method

# Arrays.LastRowIndex

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2020r2. Please use `Arrays.LastIndex<arrays.lastindex>` as a replacement.

</div>

## Description

Returns the row index of the last row of the array. The optional parameter allows you to get the last row index of a specific dimension if the array is multi-dimensional.

## Usage

*result* = *array*.**LastRowIndex**(index)

| Part      | Type                               | Description                                                                                                      |
|-----------|------------------------------------|------------------------------------------------------------------------------------------------------------------|
| result    | `Integer</api/data_types/integer>` | The index of the last element in the array specified.                                                            |
| array     | Array of any data type             | The array whose last element number you want.                                                                    |
| dimension | `Integer</api/data_types/integer>` | Relevant only for multi-dimensional arrays. Used to specify the dimension for which you want the last row index. |

## Notes

All arrays are indexed starting at position 0. Arrays can have a maximum index value of 2,147,483,646.

For multi-dimensional arrays, <span class="title-ref">LastRowIndex</span> returns the index of the last row of the dimension you specify, or, if you do not specify a dimension, it returns the value for the first dimension. The first dimension is numbered 1.

## Sample code

This code replaces each occurrence of X in an array with Y.

``` xojo
For i As Integer = names.FirstRowIndex To names.LastRowIndex
  If names(i) = "X" Then
    names(i) = "Y"
  End If
Next
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The following code returns -1 because the newly-declared array has no elements:

``` xojo
Var i() As Integer
Var j As Integer
j = i.LastRowIndex
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The following code of a 2-dimensional array returns 5 in the variable i and 3 in the variable j (remember that the first dimension is numbered 1).

``` xojo
Var i, j As Integer
Var aNames (5, 3) As String
i = aNames.LastRowIndex
j = aNames.LastRowIndex(2)
```

## Compatibility

All project types on all supported operating systems.

## See also

`Arrays</api/language/arrays>` parent class; `Var</api/language/var>` statement; `Arrays</api/language/arrays>` concept; `ParamArray</api/language/paramarray>` keyword, `Arrays.FirstIndex<arrays.firstindex>` method
