Click here to Skip to main content
15,881,139 members
Home / Discussions / C#
   

C#

 
GeneralRe: 'out' keyword, to use or not to use Pin
Sander Rossel19-Apr-16 21:26
professionalSander Rossel19-Apr-16 21:26 
GeneralRe: 'out' keyword, to use or not to use Pin
Mycroft Holmes19-Apr-16 21:54
professionalMycroft Holmes19-Apr-16 21:54 
GeneralRe: 'out' keyword, to use or not to use Pin
Foothill20-Apr-16 5:03
professionalFoothill20-Apr-16 5:03 
GeneralRe: 'out' keyword, to use or not to use Pin
Sander Rossel20-Apr-16 5:59
professionalSander Rossel20-Apr-16 5:59 
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 
I occasionally use the out or ref keyword, but not often at all. Personally, if I need to return more than just some result I create a class. eg. In my DAL component I have a method that executes a given query and returns a Result class instance (Result is a class I wrote, nothing .Net native)
The result class in my case contains:
* The Dataset with the returned results (if any)
* A status enum
* An exception (can be null if everything goes well)
* The executed SQL
That way I have one line of code that executes the statement and one of code that will check wether that went OK or not. Notice that I have for more flexibility in my return object and if I ever need to change it (eg add a property to the Result class) I have a lesser change of high impact on the rest of the code.

in short. out and ref can be useful in some cases, but I would not use it as a rule of thumb.
That's my opinion anyway. Smile | :)
V.
(MQOTD rules and previous solutions)

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 
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 

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.