Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Check if it is null

Reply
Thread Tools

Check if it is null

 
 
shapper
Guest
Posts: n/a
 
      10-11-2006
Hello,

I have 3 different properties in a class. The properties are of types:

Mail.MailPriority, Mail.MailAddress and Mail.MailAddressCollection

I wan to check if the properties were defined, i.e., if they are null
or not.

I was able to work this out for properties of type boolean and string
but not for these ones.

Could someone help me out?

Thanks,

Miguel

 
Reply With Quote
 
 
 
 
Karl Seguin [MVP]
Guest
Posts: n/a
 
      10-11-2006

Well, MailPriority is an enum of base type int32...by default int's default
to 0... so you can't check if it's null. It'll always be atleast set to
MailPriority.Normal (which is 0).


For MailAddress and MailAddressCollection you can do check if they are null
like:

if (mailAddress == null)
{
//!!it's null
}


same thing with MailAddressCollection, but you can also check if it's Count
== 0

if (mailAddressCollection== null || mailAddressCollection.Count == 0)
{
//it's null
}


in vb.net:

if mailAddress is nothing then


and instead of || use "OrElse"

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


"shapper" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hello,
>
> I have 3 different properties in a class. The properties are of types:
>
> Mail.MailPriority, Mail.MailAddress and Mail.MailAddressCollection
>
> I wan to check if the properties were defined, i.e., if they are null
> or not.
>
> I was able to work this out for properties of type boolean and string
> but not for these ones.
>
> Could someone help me out?
>
> Thanks,
>
> Miguel
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
To check or not to check for NULL? Mike Java 12 09-26-2008 10:46 PM
createImage sometime returns null and sometime returns non-null. vizlab Java 3 10-17-2007 11:21 AM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
VB.NET Null to SQL Null (ASP.NET 2.0 GridView) Kivak Wolf ASP .Net 2 06-28-2005 02:01 PM
is (!ptr) or (ptr) valid way to check for NULL or NOT NULL? G Fernandes C Programming 9 02-27-2005 03:07 AM



Advertisments