Equivalent of IllegalArgumentException in C#

Question

Monday, September 11, 2006 8:10 PM | 4 votes

I have an object that contains 4 things. I want to check to see if these 4 things are legal according to their definitions. If at least one is not, I want to throw an exception. My professor quickly wrote on the board to use the IllegalArgumentException, but it appears to not exist in C#. What would be a good equivalent of this exception that does exist?
Thanks!

All replies (2)

Monday, September 11, 2006 8:18 PM âś…Answered | 8 votes

I'd say could use the ArgumentException (argument is not valid) or more specific ArgumentOutOfRangeException (argument is not in the range of valid values).

Andrej


Monday, September 11, 2006 8:28 PM | 1 vote

Sounds perfect. Thanks!