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?
From stackoverflow
-
Yes, it would be more clear to pass the name of property.
-
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.
Justin Dearing : I guess the assumption is that the StackTrace would clarify the property in question. -
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")); }
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.