2

If you have the following function, for example:

public Tuple<int, int> GetMultipleValue()
{
     return Tuple.Create(1,2);
}

How would you access those integers in your main program, after calling GetMultipleValue()?

2 Answers 2

4

Tuple classes have properties with very "logical" names: Item1, Item2, Item3, ...

Tuple<int, int> temp = GetMultipleValue();
Console.WriteLine("{0}; {1};", temp.Item1.ToString(), temp.Item2.ToString());

From MSDN Tuple <T1, T2> Class

Sign up to request clarification or add additional context in comments.

1 Comment

@John, If this is the answer you were looking for,you should accept it. Give credit where it's due, and increase your odds of getting helpful answers in the future.
1

My understanding is that you would save your return value into a tuple object. For example

var myTuple = GetMultipleValue()

And then you can access the individual parts of the tuple by

myTuple.Item1 

or

myTuple.Item2

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.