We help IT Professionals succeed at work.

How do I check if a GUID is nothing or null?

mattphung
mattphung asked
on
Medium Priority
13,754 Views
Last Modified: 2008-02-01
How do I check if a GUID is nothing or null?
Is there a built in function lfor this?
Comment
Watch Question

just use the usual check for nothing/null

c#: if (objGUID == null)
vb: if IsNothing(objGUID) then

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
i tried:
if objGUID = nothing then
 
I get an error message "=" is not defined for type "system.GUID"

why does " Isnothing()" works but "= nothing" doesn't?
in VB.NET you can't compare an object ot nothing like that. You should also be able to use

if objGUID is nothing then


but the same applies, you cant use =nothing like you can use == null in c#
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
C#:
   if (guidVariable == Guid.Empty)

VB.NET:
  If guidVariable.Equals(Guid.Empty) Then

Bob
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.