Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use a parameter in C# to send data back to the caller?

Tags:

c#

I usually send data back to the calling code using return. However this time I have to send two kinds of data:

public IEnumerable<AccountDetail> ShowDetails(string runTime)

Is it possible for me to send the value of runTime back to the calling code?

like image 981
Samantha J T Star Avatar asked Dec 11 '11 03:12

Samantha J T Star


1 Answers

Yes, it's possible via either the ref or out keywords.

Usually, though, the need to do this points to a design failure elsewhere... not always, there are some good cases for this, but often enough that I'd want to spend a bit of time thinking about what I'm really doing first.

like image 93
Joel Coehoorn Avatar answered Nov 09 '22 23:11

Joel Coehoorn