array.length = 0 means what?

  • Thread starter Thread starter Garg
  • Start date Start date
G

Garg

if we assign

array.length = 0

then what does it mean?

Are we setting the length of the array equal to 0
or are we selecting the first element of the array?

Please help me on this..

In vb.net, this gives an error saying that .length is a read only
property.
 
Garg said:
if we assign

array.length = 0

then what does it mean?

Are we setting the length of the array equal to 0
or are we selecting the first element of the array?

Please help me on this..

In vb.net, this gives an error saying that .length is a read only
property.

In javascript you can set the length property to zero in order to
clear an array.
I'am not sure whether it have any sense in other languages.
 
Array.Length Property doesn't set length of array nor set first
element of array. It returns number of elements in all dimensions of
the array. You can use this property to check if given array is not
populated:

If myArray.Length = 0 Then
Console.WriteLine("No elements in myArray")
Else
Console.Writeline("myArray has {0} element(s)", myArray.Length)
End If
 
Back
Top