Click here to Skip to main content
15,891,657 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
TheGreatAndPowerfulOz21-Jan-18 18:11
TheGreatAndPowerfulOz21-Jan-18 18:11 
GeneralRe: C# TryParse() Pin
Gary Wheeler16-Jan-18 3:27
Gary Wheeler16-Jan-18 3:27 
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 
Splitting it in two methods would be a performance hit.
TryParse will need to evaluate the entire string (and maybe actually parse it) to then return true or false, then Parse will do everything again.
I say actually parse it because for ints (and many other types, actually) the string length and characters might be valid, yet the value overflows and the easiest way for a TryParse to detect it is to actually do the full parsing process.

That being said, most TryParse methods today would be best implemented by using a Nullable<t> (or simply T?). Unfortunately, this will only work for structs (but it would also be valid for classes if a parse is never expected to return null).
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 
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.