Re: Check if an object is null
- From: "shapper" <mdmoura@xxxxxxxxx>
- Date: 9 Oct 2006 17:43:12 -0700
I am using:
If MyObject.Equals(DBNull.Value) Then
....
Do you think this work?
At least I didn't have any problem in my code.
Thanks,
Miguel
Cowboy (Gregory A. Beamer) wrote:
In ASP.NEt 1.1 or in 2.0 without a nullable type, you would use DbNull.Value
if (x == DbNull.Value)
{
//is null
}
In 2.0, you have nullable types. I assume you are not using them however, or
are using VB.NET. In VB.NET 2.0, you use
Dim nullable1 As Nullable(Of DateTime) = New Nullable(Of DateTime)
If Not nullable1.HasValue Then
End If
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
*************************************************
Think outside of the box!
*************************************************
"shapper" <mdmoura@xxxxxxxxx> wrote in message
news:1160430331.365309.41920@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,
Inside a class I have 4 propertiy types:
1. String
2. Boolean
3. Mail.MailPriority
4. Mail.MailAddressCollection
I need to check if each property is null, i.e., if it wasn't defined
any value for them.
How can I do it?
I tried NULL but it got an error to use System.DBNull but I got error
again.
Thanks,
Miguel
.
- References:
- Check if an object is null
- From: shapper
- Re: Check if an object is null
- From: Cowboy \(Gregory A. Beamer\)
- Check if an object is null
- Prev by Date: Code in one line
- Next by Date: Re: Is this an error or what????
- Previous by thread: Re: Check if an object is null
- Next by thread: Re: ASP.NET to ATLAS transition
- Index(es):
Relevant Pages
|