# System.ArrayLen(Array of [Any] [, Integer]) Method
> Version: _Available or changed with runtime version 1.0._
Returns the total number of elements in an array or the number of elements in a specific dimension.
## Syntax
```al
Length :=   System.ArrayLen(Array: Array of [Any] [, Dimension: Integer])
```
> NOTE
> This method can be invoked without specifying the data type name.
## Parameters
Array
Type: ../any/any-data-type
The array that you want to investigate.
*[Optional] Dimension*
Type: ../integer/integer-data-type
If you omit this optional argument, the method returns the total number of elements in the array. To get the number of elements in a specific dimension, use Dimension with a valid value. The valid values are determined by the number of dimensions of the input array. For example, the valid values for a three-dimensional array would be 1, 2, and 3.
## Return Value
Length
Type: ../integer/integer-data-type
## Remarks
If you use ArrayLen with an input parameter that is not an array, a run-time error occurs.
## Example
This example shows how to use the ArrayLen method.
```al
var
    Array1: array[2] of Integer;
    Array2: array[3,4] of Integer;
begin
    Message('Array1, Total number of elements: %1', ArrayLen(Array1));
    Message('Array2, Dimension 1 size: %1', ArrayLen(Array2,1));
    Message('Array2, Dimension 2 size: %1', ArrayLen(Array2,2));
    Message('Array2, Total number of elements: %1', ArrayLen(Array2));
end;
```
The following messages are displayed.
Array1, Total number of elements: 2
Array2, Dimension 1 size: 3
Array2, Dimension 2 size: 4
Array2, Total number of elements: 12
## Related information
system-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-arraylen-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/system/system-arraylen-method/
