array question

usvpn

Freshman
Joined
Apr 19, 2010
Messages
45
See also, XVBT

Hi,
I use:

Dim MyArray() As String = = EmailMessage.GetHeaderField("Disposition-Notification-To")

EmailMessage is a 3rd party component, now it may or may not have anything, so the array is null/nothing in that case.
In that case, any operation on array will return System.NullReferenceException
Even if I want to check if the array :

If MyArray IsNot Nothing
or
If MyArray.Length = 0

All will result in System.NullReferenceException
How to check such an array at all?
Thanks.
 
Last edited by a moderator:
First, get rid of the double equals (==). That is 'C' syntax.

Next, have you tried the logic backwards and using parenthesis?

Visual Basic:
If (MyArray Is Nothing) Then
  Return
End If
' Process your code here
 
Back
Top