Here is some simple code to validate that an array is valid. Before trying to use an array, you should always validate it with this code first.
Public Shared Function IsValidArray(ByVal array As Array) As Boolean
Dim valid As Boolean = False
If array Is Nothing Then
Throw New ArgumentNullException(“array”)
End If
If (array IsNot Nothing) AndAlso (array.Length > 0) Then
valid = True
End If
Return valid
End Function
Tip By: David McCater
This code can be found in the open source dotNetTips.Utility assembly
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.
