Is there a known reason why FormatException
does not inherit from ArgumentException
? An invalid format would seem to be a very specific case of an argument being invalid, similar to ArgumentOutOfRangeException
.
The MSDN article for the class states:
FormatException is thrown when the format of an argument in a method invocation does not match the format of the corresponding formal parameter type. For example, if a method specifies a
String
parameter consisting of two digits with an embedded period, passing a corresponding string argument containing only two digits to that method would cause FormatException to be thrown.
Sounds like just the scenario for an ArgumentException
or deriving class to me.
All this means is that you can't deal with FormatException
under the larger ArgumentException
exception family, nor can you identify which parameter caused the exception to be thrown.
Is there any reason for this seemingly out-of-place exception to be where it is?