Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is it better to use args to return values or function type? Pin
led mike5-Mar-07 11:38
led mike5-Mar-07 11:38 
GeneralRe: Is it better to use args to return values or function type? Pin
Colin Angus Mackay5-Mar-07 13:52
Colin Angus Mackay5-Mar-07 13:52 
AnswerRe: Is it better to use args to return values or function type? Pin
Ed.Poore5-Mar-07 11:38
Ed.Poore5-Mar-07 11:38 
AnswerRe: Is it better to use args to return values or function type? Pin
netJP12L5-Mar-07 11:39
netJP12L5-Mar-07 11:39 
GeneralRe: Is it better to use args to return values or function type? Pin
DavidNohejl5-Mar-07 13:00
DavidNohejl5-Mar-07 13:00 
AnswerRe: Is it better to use args to return values or function type? Pin
Guffa5-Mar-07 12:47
Guffa5-Mar-07 12:47 
AnswerRe: Is it better to use args to return values or function type? Pin
DavidNohejl5-Mar-07 12:59
DavidNohejl5-Mar-07 12:59 
AnswerRe: Is it better to use args to return values or function type? Pin
Mundo Cani5-Mar-07 16:42
Mundo Cani5-Mar-07 16:42 
Generally, the second option is the best (for many of the reasons already mentioned) and is what you should use most of the time. There are, however, times when passing parameters by reference is useful. For example, a function may need to return multiple values (this is often a sign that refactoring is in order, but there are legitimate examples of this need). Also, when passing a large value type by value, the type must be copied. This takes extra memory and cycles. Because of this, it may be acceptable (and even neccessary) at times to pass a large value type by reference.

Also, when passing parameters by reference, C# requires the 'out' or 'ref' keywords. Although they are compiled into identical IL, when using the 'out' keyword, it is expected that the method being called will initialize the value. When 'ref' is used, it is expected that the calling method will initialize the value.

So, while you won't usually need (or want) to pass by reference, there are times when it is appropriate.

Ian

QuestionFile deleting Pin
SpeedBee5-Mar-07 11:09
SpeedBee5-Mar-07 11:09 
AnswerRe: File deleting Pin
Ed.Poore5-Mar-07 11:37
Ed.Poore5-Mar-07 11:37 
AnswerRe: File deleting Pin
Luc Pattyn5-Mar-07 13:28
sitebuilderLuc Pattyn5-Mar-07 13:28 
AnswerRe: How to convert object type into 'int' type? Pin
Are Jay5-Mar-07 9:41
Are Jay5-Mar-07 9:41 
GeneralRe: How to convert object type into 'int' type? Pin
Khoramdin5-Mar-07 9:51
Khoramdin5-Mar-07 9:51 
GeneralRe: How to convert object type into 'int' type? Pin
Colin Angus Mackay5-Mar-07 13:51
Colin Angus Mackay5-Mar-07 13:51 
QuestionDateTimepicker commercial replacement ? Pin
CAE5-Mar-07 8:45
CAE5-Mar-07 8:45 
Questionsend a wav file through a socket in C# Pin
trab0075-Mar-07 7:33
trab0075-Mar-07 7:33 
AnswerRe: send a wav file through a socket in C# Pin
Ennis Ray Lynch, Jr.5-Mar-07 10:18
Ennis Ray Lynch, Jr.5-Mar-07 10:18 
GeneralRe: send a wav file through a socket in C# Pin
trab0075-Mar-07 20:56
trab0075-Mar-07 20:56 
QuestionTrouble updating Access DB in C# [modified] Pin
bward845-Mar-07 6:50
bward845-Mar-07 6:50 
AnswerRe: Trouble updating Access DB in C# Pin
Guffa5-Mar-07 9:03
Guffa5-Mar-07 9:03 
GeneralRe: Trouble updating Access DB in C# Pin
bward845-Mar-07 9:05
bward845-Mar-07 9:05 
Question.Net Framework version Problem Pin
Abu Syed Khan5-Mar-07 6:41
Abu Syed Khan5-Mar-07 6:41 
AnswerRe: .Net Framework version Problem Pin
Ed.Poore5-Mar-07 11:35
Ed.Poore5-Mar-07 11:35 
GeneralRe: .Net Framework version Problem Pin
Abu Syed Khan6-Mar-07 3:41
Abu Syed Khan6-Mar-07 3:41 
GeneralRe: .Net Framework version Problem Pin
Ed.Poore6-Mar-07 4:39
Ed.Poore6-Mar-07 4:39 

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.