Throwing Argument exception when method argument is a Guid

  • Thread starter Thread starter Andy B
  • Start date Start date
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?
 
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"); }
 
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
///

;-)
 
Back
Top