Click here to Skip to main content
15,879,095 members
Home / Discussions / C#
   

C#

 
AnswerRe: 'out' keyword, to use or not to use Pin
Gerry Schmitz19-Apr-16 12:36
mveGerry Schmitz19-Apr-16 12:36 
AnswerRe: 'out' keyword, to use or not to use Pin
Bernhard Hiller19-Apr-16 21:25
Bernhard Hiller19-Apr-16 21:25 
GeneralRe: 'out' keyword, to use or not to use Pin
Foothill20-Apr-16 3:16
professionalFoothill20-Apr-16 3:16 
AnswerRe: 'out' keyword, to use or not to use Pin
V.19-Apr-16 22:04
professionalV.19-Apr-16 22:04 
GeneralRe: 'out' keyword, to use or not to use Pin
Foothill20-Apr-16 3:13
professionalFoothill20-Apr-16 3:13 
AnswerRe: 'out' keyword, to use or not to use Pin
OriginalGriff19-Apr-16 23:00
mveOriginalGriff19-Apr-16 23:00 
GeneralRe: 'out' keyword, to use or not to use Pin
Foothill20-Apr-16 3:23
professionalFoothill20-Apr-16 3:23 
GeneralRe: 'out' keyword, to use or not to use Pin
OriginalGriff20-Apr-16 3:50
mveOriginalGriff20-Apr-16 3:50 
No, the fact that it's user input doesn't matter.
It's that you need to return two values (in this example a good/bad signal and a processed result) where there isn't the option of including a "bad" indication in the result.
For reference types, a "bad" result can be null and anything else is OK - but with value types that isn't possible, and returning a nullable value type is exactly the same (in practice) as returning a special type that contains both results. But with the added complication that it can't be used directly once it's returned! Laugh | :laugh:
And throwing exceptions is fine and dandy, but I don't like using them as a part of "normal" processing - they are exceptional events, and have a cost associated (The True Cost of .NET Exceptions — Solution | Rico Mariani's Performance Tidbits[^] describes the situation nicely). Plus the code becomes ugly and tends to get omitted by beginners, so instead of teaching them good practices, they just ask the same old question in QA! Wink | ;)
Plus, as Pete said in the thread below mine, returning a bool and an out parameter means that you don't need to pollute the heap with "extra" info, and the bool value doesn't persist.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

GeneralRe: 'out' keyword, to use or not to use Pin
Foothill20-Apr-16 4:15
professionalFoothill20-Apr-16 4:15 
GeneralRe: 'out' keyword, to use or not to use Pin
OriginalGriff20-Apr-16 4:30
mveOriginalGriff20-Apr-16 4:30 
GeneralRe: 'out' keyword, to use or not to use Pin
Foothill20-Apr-16 5:00
professionalFoothill20-Apr-16 5:00 
GeneralRe: 'out' keyword, to use or not to use Pin
OriginalGriff20-Apr-16 5:12
mveOriginalGriff20-Apr-16 5:12 
GeneralRe: 'out' keyword, to use or not to use Pin
Foothill20-Apr-16 5:41
professionalFoothill20-Apr-16 5:41 
GeneralRe: 'out' keyword, to use or not to use Pin
OriginalGriff20-Apr-16 6:22
mveOriginalGriff20-Apr-16 6:22 
GeneralRe: 'out' keyword, to use or not to use Pin
Foothill20-Apr-16 7:16
professionalFoothill20-Apr-16 7:16 
AnswerRe: 'out' keyword, to use or not to use Pin
Pete O'Hanlon19-Apr-16 23:01
mvePete O'Hanlon19-Apr-16 23:01 
GeneralRe: 'out' keyword, to use or not to use Pin
Nathan Minier20-Apr-16 1:51
professionalNathan Minier20-Apr-16 1:51 
GeneralRe: 'out' keyword, to use or not to use Pin
Pete O'Hanlon20-Apr-16 2:06
mvePete O'Hanlon20-Apr-16 2:06 
GeneralRe: 'out' keyword, to use or not to use Pin
Nathan Minier20-Apr-16 2:17
professionalNathan Minier20-Apr-16 2:17 
GeneralRe: 'out' keyword, to use or not to use Pin
Pete O'Hanlon20-Apr-16 2:36
mvePete O'Hanlon20-Apr-16 2:36 
GeneralRe: 'out' keyword, to use or not to use Pin
Foothill20-Apr-16 3:42
professionalFoothill20-Apr-16 3:42 
GeneralRe: 'out' keyword, to use or not to use Pin
Richard Deeming20-Apr-16 4:19
mveRichard Deeming20-Apr-16 4:19 
AnswerRe: 'out' keyword, to use or not to use Pin
Ian A Davidson20-Apr-16 0:09
Ian A Davidson20-Apr-16 0:09 
GeneralRe: 'out' keyword, to use or not to use Pin
Foothill20-Apr-16 4:34
professionalFoothill20-Apr-16 4:34 
QuestionWhile button is clicked Pin
tvks19-Apr-16 8:30
tvks19-Apr-16 8:30 

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.