C# – Return multiple values to a method caller

creturn

I read the C++ version of this question but didn't really understand it.

Can someone please explain clearly if it can be done in C#, and how?

Best Answer

In C# 7 and above, see this answer.

In previous versions, you can use .NET 4.0+'s Tuple:

For Example:

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

Tuples with two values have Item1 and Item2 as properties.