Array.Length Property
.NET Framework (current version)
Gets the total number of elements in all the dimensions of the Array.
Assembly: mscorlib (in mscorlib.dll)
| Exception | Condition |
|---|---|
| OverflowException | The array is multidimensional and contains more than MaxValue elements. |
Retrieving the value of this property is an O(1) operation.
The following example uses the Length property to get the total number of elements in an array. It also uses the GetUpperBound method to determine the number of elements in each dimension of a multidimensional array.
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: