Welcome to thinktecture forums Sign in | Join | Faq

Discussion

Started by dimam at 12-04-2007 6:45 PM. Topic has 0 replies.

Print Search
Sort Posts:    
   12-04-2007, 6:45 PM
dimam is not online. Last active: 12/4/2007 4:22:24 PM dimam

Top 500 Posts
Joined on 12-04-2007
Posts 1
Null vs. Empty String issue
Hello,

When the datacontract code is generated with the "Public property" option enabled, you get a code similar to this (for each attribute of a datacontract):
                          <System.Xml.Serialization.XmlAttributeAttribute(AttributeName:="ProcessCorrelationID")>  _
Public Property ProcessCorrelationID() As String
    Get
        Return Me._processCorrelationID
    End Get
    Set
        If (Me._processCorrelationID <> value) Then
            Me._processCorrelationID = value
        End If
    End Set
End Property

Now, if I want to set an empty string ("") to the ProcessCorrelationID property, it will not get set as the "If (Me._processCorrelationID <> value) Then" statement returns false when the _processCorrelationID is Nothing.

Well, I can write the following code to get around this and set the ProcessCorrelationID value to an empty string:
var.ProcessCorrelationID = "foo"
var.ProcessCorrelationID = ""

But this code just does not look right. Are there other workarounds? Is there a way you could fix this issue?

I am also curious, why do you need the "if" statement anyway? Wouldn't this work as well?

Set(ByVal value As String)
    Me.lockingMachineField = Value
End Set


Thanks!
Dima
   Report 
thinktecture fo... » WSCF » Discussion » Null vs. Empty String issue

Powered by Community Server, by Telligent Systems