Throwing Argument exception when method argument is a Guid

A

Andy B

I have a method that takes a Guid as a parameter. I want to test to see if
it has any value and if not throw argument exception. How do i do this?
 
J

Josip Medved

I have a method that takes a Guid as a parameter. I want to test to see if
it has any value and if not throw argument exception. How do i do this?

Try this:
if (param == Guid.Empty) { throw new ArgumentException("Some
text", "param"); }
 
H

Herfried K. Wagner [MVP]

Josip Medved said:
Try this:
if (param == Guid.Empty) { throw new ArgumentException("Some
text", "param"); }

In VB:

\\\
If param = Guid.Empty Then
Throw New ArgumentException(...)
End If
///

;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top