PC Review


Reply
Thread Tools Rate Thread

Check to see if object instance exists

 
 
Larry
Guest
Posts: n/a
 
      21st Feb 2007

Thanks in advance.
what is the C# equivalent of the VB.net IsNothing(object) function?
just trying to check to see if an object instance already exists.
does someone have an example?


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      21st Feb 2007
Larry <(E-Mail Removed)> wrote:
> Thanks in advance.
> what is the C# equivalent of the VB.net IsNothing(object) function?
> just trying to check to see if an object instance already exists.
> does someone have an example?


Well, if what you mean is that you want to see if the value of a
variable refers to an object or not, you want:

if (x==null)

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Freiddy
Guest
Posts: n/a
 
      21st Feb 2007
On Feb 21, 6:33 pm, Larry <l...@nospamhere.com> wrote:
> Thanks in advance.
> what is the C# equivalent of the VB.net IsNothing(object) function?
> just trying to check to see if an object instance already exists.
> does someone have an example?
>
> *** Sent via Developersdexhttp://www.developersdex.com***


It's quite easy: you just compare to "null"

object someobject;
someobject = someMethod();
if (someobject == null)
{
// if it's null, then what?
}

Does that solve your problems?

--Freiddy
http://fei.yuanbw.googlepages.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
How to check object exists if it raises error? Mark Berry Microsoft C# .NET 4 15th Jun 2007 11:53 PM
check if name object exists mark kubicki Microsoft Excel Programming 1 18th Jan 2007 10:40 PM
Check if a table object exists =?Utf-8?B?TWFyaWVU?= Microsoft Access VBA Modules 1 27th Sep 2006 07:12 PM
Check if previous instance of application exists Hubert Hermanutz Microsoft C# .NET 3 12th Feb 2004 08:29 AM
Can you check if an object exists, and only it it does, delete it =?Utf-8?B?Q3JhaWc=?= Microsoft Access Macros 2 19th Dec 2003 01:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:42 AM.