jeudi 17 décembre 2015

Check if Newtonsoft.Json.Linq.JToken is nothing

According to the Debugger, I've got a variable called myCancelled of type Newtonsoft.Json.Linq.Jtoken with a value of Nothing. My question is simply: How do I check if it's Nothing/Null/False/Empty?

Here's what I've tried. None of these conditions evaluate to true:

            If myCancelled Is Nothing Then
                'Doesn't come here
            End If
            If myCancelled = DBNull.Value.ToString Then
                'Doesn't come here
            End If
            If myCancelled = "null" Then
                'Doesn't come here
            End If
            If IsDBNull(myCancelled) Then
                'Doesn't come here
            End If
            If myCancelled Is DBNull.Value Then
                'Doesn't come here
            End If
            If String.IsNullOrEmpty(myCancelled) = True Then
                'Doesn't come here
            End If
            If myCancelled.ToString = "Nothing" Then
                'Runtime error
            End If

I'm new to VB.net so any pointers are appreciated.

Aucun commentaire:

Enregistrer un commentaire