Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return more than one value in C# 1

Status
Not open for further replies.

NoviceNet

Programmer
May 26, 2005
15
US
I need to return more than one value in a c# function. Just like 'Return a,b,c,d'. How do I do that?
 
Solution 1:
Define a class with that a,b,c,d;
Then return an instance of that class;
class Toto
{
Type1 a;
Type2 b;
Type3 c;
Type4 d;
}

Toto GetToto()
{
//..
Toto t= new Toto();
return t;
}
Solution 2:
Pass that a,b,c,d types by reference.
void Func( ref Type1 a, ref Type2 b, ref Type3 c, ref Type4 d)
{
// here access/modify a,b,c,d

}
Solution 3:
Add that a,b,c,d objects to an ArrayList and return that array.
obislavu
 
Yes, as the example with ref but you cannot write "Return a,b,c,d";
obislavu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top