Recently I've noticed that when we've been doing string comparisons in our .NET code we have been safeguarding against null references. This check seems unnecessary in VB.NET because it overloads the equality operator and performs this null ref check for us. Do you all agree ?
See examples below:
Dim myStringVariable As String
' Unnecessary in VB.NET
If myStringVariable Is Nothing OrElse myStringVariable = "" Then
End If
' Unnecessary in VB.NET
If String.IsNullOrEmpty(myStringVariable) Then
End If
' This will work
If myStringVariable = "" Then
End If
' Also acceptable if you don't like using hard coded constants
If myStringVariable = String.Empty Then
End If