If an invalid value is passed to a property setter and an ArgumentException-ish exception is thrown, what should be passed as paramName? "value", since it seemingly is the actual argument? Wouldn't it be more clear to pass the name of the propery instead?
+6
A:
ArgumentExceptions contain the name of the parameter which is not valid. For a property setter the actual parameter is named value (in both source and generated code). It's more consistent to use this name.
JaredPar
2009-03-25 13:01:46
I guess the assumption is that the StackTrace would clarify the property in question.
Justin Dearing
2010-10-13 19:52:38
+2
A:
After extensive poking around with Reflector (trying to find a CLR object with a writable Property), the first one I found (FileStream.Position) using "value" as the argument name:
if (value < 0L)
{
throw new ArgumentOutOfRangeException("value",
Environment.GetResourceString("NeedNonNegNum"));
}
James Curran
2009-03-25 13:39:51