Length Property
Collapse the table of content
Expand the table of content

Array.Length Property

 

Gets the total number of elements in all the dimensions of the Array.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

member Length : int with get

Property Value

Type: System.Int32

The total number of elements in all the dimensions of the Array; zero if there are no elements in the array.

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.

No code example is currently available or this language may not be supported.

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
Return to top
Show:
© 2016 Microsoft