Click here to Skip to main content
15,892,072 members

Survey Results

"out" parameters: A good idea or a bad idea?

Survey period: 15 Jan 2018 to 22 Jan 2018

Given that it has its own Code Analysis warning we know where some people stand on this.

OptionVotes% 
They are a Good Thing1029.66
They are fine if used wisely43240.91
They are what they are15414.58
They should probably be avoided where possible20119.03
They should never be used. Ever.393.69
I have no idea.12812.12



 
GeneralRe: C# TryParse() Pin
PeejayAdams16-Jan-18 3:58
PeejayAdams16-Jan-18 3:58 
GeneralRe: C# TryParse() Pin
obermd16-Jan-18 4:42
obermd16-Jan-18 4:42 
GeneralRe: C# TryParse() Pin
Richard Deeming16-Jan-18 3:35
mveRichard Deeming16-Jan-18 3:35 
GeneralRe: C# TryParse() Pin
Paulo Zemek17-Jan-18 8:17
mvaPaulo Zemek17-Jan-18 8:17 
GeneralRe: C# TryParse() Pin
Jon McKee16-Jan-18 9:12
professionalJon McKee16-Jan-18 9:12 
GeneralRe: C# TryParse() Pin
Paulo Zemek17-Jan-18 8:16
mvaPaulo Zemek17-Jan-18 8:16 
GeneralRe: C# TryParse() Pin
PeejayAdams18-Jan-18 0:03
PeejayAdams18-Jan-18 0:03 
GeneralRe: C# TryParse() Pin
Paulo Zemek18-Jan-18 7:31
mvaPaulo Zemek18-Jan-18 7:31 
TryParse doesn't use exceptions as a method of flow control. Parse does. TryParse returns a boolean (the exception is only for null values, if I'm not wrong).

About validating with regular expressions, it would be actually much slower than doing the actual TryParse, and that means pre-validating to do a parse will be slower than the entire operation.

In the end, what happens is that now we have more alternatives than out parameters. For ints, for example, using int? (that is, Nullable<int>) would do the job pretty well. I never really tried to check the performance difference to see if there's any, but it looks nicer than the out parameter.
GeneralRe: C# TryParse() Pin
F-ES Sitecore1-Feb-18 5:40
professionalF-ES Sitecore1-Feb-18 5:40 
GeneralRe: C# TryParse() Pin
Kevin McFarlane19-Jan-18 4:17
Kevin McFarlane19-Jan-18 4:17 
GeneralRe: C# TryParse() Pin
TheGreatAndPowerfulOz21-Jan-18 18:08
TheGreatAndPowerfulOz21-Jan-18 18:08 
GeneralThey used to be useful, not anymore Pin
Patje14-Jan-18 22:07
Patje14-Jan-18 22:07 
GeneralThey're palatable Pin
Mike Hankey14-Jan-18 18:15
mveMike Hankey14-Jan-18 18:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.