What is the best way to Set or Get an empty string?
Posted on 2011-04-25
I have the following (relatively) straightforward property:
Private Property _firstNm As String
Public Property FirstNm As String
Set(ByVal value As String)
If _firstNm <> value Then
If ObjectState = AssignedClaims.ObjectState.Unchanged Then
ObjectState = AssignedClaims.ObjectState.Changed
_firstNm = value
This property is causing me problems because if the setter is entered with a value of String.Empty, the test of _firstNm (which is nothing) = value (which is string.empty) returns true and I end up not entering my IF statement and bad things happen.
Is there a standard way of handling this situation? Should I change my setter (to use IsNothing(_firstNm) or change my getter?