Why are ‘out’ parameters in .NET a bad idea?
I was recently asked this, but I had no real answer besides it’s simply unnecessarily complicating an application. What other reasons are there?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, they aren’t a bad idea I think.
Dictionary<K, V>has aTryGetValuemethod which is a very good example why out parameters are sometimes a very nice thing to have.You should not overuse this feature of course, but it’s not a bad idea per definition. Especially not in C# where you have to write down the
outkeyword in function declaration and call which makes it obvious what’s going on.