Return an array, containing the values.
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
Is C# not an OO language, can you not just return an Object cantaining the two attributes. By returning a Class (Object) you have much more freedom.
Kate Albany
Junior Poster in Training
71 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
As SethWebster explained, you return an array.
If there are more value with different type (int, decimal, string, ...) you return an object array.
If there are all the values of the same type, you can return the same type:
public int[] Returnmethod()
{
int a = 1;
int b = 2;
return new int[] {a , b };
}
Mitja
Mitja Bonca
Nearly a Posting Maven
2,485 posts since May 2009
Reputation Points: 641
Solved Threads: 474
To me an array can be considered as ONE value.
A method that returns two values could be:
static int toreturn(int inint, out bool bbool)
{
if (inint == 42) bbool = true;
else bbool = false;
return inint*2;
}
This would return the double value ofinint and [the return of B]bbool [/B]via out, would only be true if the initial value of inint is equal to 42.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
Nice way to resurrect a 6 year old thread :)
Momerath
Nearly a Senior Poster
3,386 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558