ArgumentOutOfRangeException - Cannot resolve symbol
R
marks the following code as an error:
public static long Factorial(long value)
{
if (value < 0)
{
throw new ArgumentOutOfRangeException("vvalue must be greater than 0"); // the
}
return 0;
}
The error is : Cannot resolve symbol 'value must be greater than 0'
Please sign in to leave a comment.
Hello,
ReSharper is right, first argument should be parameter name, and the second
(if any) can be message. So you should rewrite it as
throw new ArgumentOutOfRangeException("value", "value must be greater than
0");
It is known mess in .NET API, because ArgumentException, which is base class
for ArgumentOutOfRangeException has the reverse order of parameters. That's
why we introduced this check :)
Sincerely,
Ilya Ryzhenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
IR> R# marks the following code as an error:
IR>
IR> public static long Factorial(long value)
IR> {
IR> if (value < 0)
IR> {
IR> throw new ArgumentOutOfRangeException("vvalue must
IR> be greater than 0"); // the
IR> }
IR> return 0;
IR> }
IR> The error is : Cannot resolve symbol 'value must be greater than 0'
IR>
Ohh I see. Good catch.
I was using the overload public ArgumentOutOfRangeException(string paramName), but expecting it just to be "message", as most .NET exceptions.