{"title":"System.ArrayLen(Array of [Any] [, Integer]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/system/system-arraylen-method/","by":"JOP-AL","license":"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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-arraylen-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Returns the total number of elements in an array or the number of elements in a specific dimension.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"System.ArrayLen(Array of [Any] [, Integer]) Method","slug":"systemarraylenarray-of-any-integer-method","at":0,"chars":1764},{"level":2,"title":"Syntax","slug":"syntax","at":213,"chars":169},{"level":2,"title":"Parameters","slug":"parameters","at":382,"chars":494},{"level":2,"title":"Return Value","slug":"return-value","at":876,"chars":58},{"level":2,"title":"Remarks","slug":"remarks","at":934,"chars":102},{"level":2,"title":"Example","slug":"example","at":1036,"chars":594},{"level":2,"title":"Related information","slug":"related-information","at":1630,"chars":134}],"text":"# System.ArrayLen(Array of [Any] [, Integer]) Method\n> Version: _Available or changed with runtime version 1.0._\nReturns the total number of elements in an array or the number of elements in a specific dimension.\n## Syntax\n```al\nLength :=   System.ArrayLen(Array: Array of [Any] [, Dimension: Integer])\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nArray\nType: ../any/any-data-type\nThe array that you want to investigate.\n*[Optional] Dimension*\nType: ../integer/integer-data-type\nIf 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.\n## Return Value\nLength\nType: ../integer/integer-data-type\n## Remarks\nIf you use ArrayLen with an input parameter that is not an array, a run-time error occurs.\n## Example\nThis example shows how to use the ArrayLen method.\n```al\nvar\n    Array1: array[2] of Integer;\n    Array2: array[3,4] of Integer;\nbegin\n    Message('Array1, Total number of elements: %1', ArrayLen(Array1));\n    Message('Array2, Dimension 1 size: %1', ArrayLen(Array2,1));\n    Message('Array2, Dimension 2 size: %1', ArrayLen(Array2,2));\n    Message('Array2, Total number of elements: %1', ArrayLen(Array2));\nend;\n```\nThe following messages are displayed.\nArray1, Total number of elements: 2\nArray2, Dimension 1 size: 3\nArray2, Dimension 2 size: 4\nArray2, Total number of elements: 12\n## Related information\nsystem-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}