By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,115 Members | 894 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,115 IT Pros & Developers. It's quick & easy.


P: n/a
I am throwing the ArgumentOutOfRangeException in my code as shown below

throw new ArgumentOutOfRangeException("value", "Value must be 0");

my catch block is below

catch(ArgumentOutOfRangeException exception)
MessageBox.Show(exception.Message,"Input Error",

} // end catch

My question is the message box shows both my custom error of "Value must be
0. and paramamter name=value. Why is it displaying parameter name when all
I am requesting is the exception.Message? Thanks for your help.
Nov 13 '07 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Simply because that is how ArgumentOutOfRangeException chooses to
format it's inner message when a parameter name is supplied; can't
really do much about it unless you a: don't supply the param-name, b:
reformat it, or c: catch the specific type and display your own

string actualMsg =
new ArgumentOutOfRangeException("ParamName",

Parameter name: ParamName

Nov 13 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.