When would you use InvalidArgumentException versus OutOfRangeException for parameters to a method? Would you lean more towards OutOfRangeException for a parameter that is not correct (e.g. empty string)?
+2
A:
I'd use the OutOfRangeException only when working with arrays / collections and a given index is incorrect.
InvalidArgumentException is more suited to the case of passing an empty string if a non-empty string is required.
Glen
2009-08-12 14:18:43
http://msdn.microsoft.com/en-us/library/system.argumentoutofrangeexception.aspx states that ArgumentOutOfRange is "thrown when the value of an argument is outside the allowable range of values" but doesn't make any mention of array/collection usage.
David in Dakota
2009-08-12 15:29:36