How do I check the size of an array? I want a condition where BlockList() has nothing in it.
Dim BlockList() As String
If BlockList size is 0 Then
end if
Printable View
How do I check the size of an array? I want a condition where BlockList() has nothing in it.
Dim BlockList() As String
If BlockList size is 0 Then
end if
If BlockList.Length =0 Then :)
Use "is" for reference types only
Be aware that, while the Length property is a value type, the array itself is a reference type. This code:will throw an exception because no Array object has been created. To create an array with no elements, use this code:Code:Dim myArray() As String
If myArray.Length = 0 Then
MessageBox.Show("No elements.")
End If
orCode:Dim myArray(-1) As String
orCode:Dim myArray() As String = New String(-1) {}
The array variable is a null reference until you either specify the upper bound of each dimension or assign an existing array object to it.Code:Dim myArray() As String = {}