We can return multiple values from a function using the following 3 approaches:
Reference parameters
Output parameters
Returning an Array
Returning an object of class/struct type
Returning a Tuple
Interviews9 answers
Is it possible that a method can return multiple value at a time?
9 Answers
Rajeev KumarPosted Mar 1, 2023, 8:58 AM EST
No, a method cannot return more than one values. You can use other techniques. If you want to get more than one value from a method then you can simply change the return to a custom or object type
Ishoo AnyalPosted Sep 27, 2019, 3:52 AM EDT
Yes it is possible by using TUPLE.
Sandeep KumarPosted Feb 27, 2018, 7:13 PM EST
Yes ,You can return multiple values in a single method using ref/out keywords
Md ShahnawazPosted Feb 20, 2018, 10:19 PM EST
Yes. Simplest way is to use 'Tuple'. Which was introduced in C# 4.0
Prior to the introduction of tuples in .NET, there were three common ways to do so.
Out parameters
Class or struct types
Anonymous types returned through a dynamic return type
Sathiya MoorthyPosted Feb 17, 2018, 8:34 PM EST
You can achieve with a workaround. By definition method return one value.
# You can use out parameter and Tuples. The newly introduced in c#.
Tushar DikshitPosted Feb 13, 2018, 5:41 AM EST
Yes, using Out Parameter, which is used when you want a method to return more than one values.
int Total = 0, Product = 0;
SimpleMethod(10, 20, out Total, out Product);
Console.WriteLine("Sum = {0}, Product = {1}", Total, Product);
public static void SimpleMethod(int FN, int SN, out int Sum, out int Product)
{
Sum = FN + SN;
Product = FN * SN;
}
SAUMYA TIWARIPosted Feb 9, 2018, 6:38 AM EST
Yes , you can return multiple values in a single method using TUPLE
Naresh SinghalPosted Feb 4, 2018, 11:42 PM EST
No it is not. You can return an object though and that object can contain multiple properties –
Gajendra JangidPosted Jan 30, 2018, 7:22 PM EST






