Interviews30 answers
Can a method Return More than one Value?
30 Answers
Yes
vidya shrungarePosted Aug 11, 2021, 1:35 PM EDT
Yes
Riya updatesPosted Aug 4, 2021, 10:23 AM EDT
Yes
Prasant JaiswalPosted Jul 30, 2021, 11:05 AM EDT
Yes
spoorthi Pallakki pallakkiPosted Sep 25, 2020, 5:52 PM EDT
No, but we can achieve with array
jagadish pampanaPosted Feb 14, 2019, 2:10 PM EST
yes
Shailesh MauryaPosted Feb 14, 2019, 5:50 AM EST
yes
Johan SequeiraPosted Jan 29, 2019, 8:58 AM EST
Yes
aamir aliPosted May 4, 2018, 8:15 AM EDT
Generally method return only one value but if we want method should return multiple values then it is possible. there are many option that make method to return multiple values. we can use tuple,ref,out....etc
sushil kumarPosted Feb 9, 2017, 7:55 AM EST
Yes
Joe WilsonPosted Dec 11, 2015, 10:53 AM EST
yes
Sanjay MauryaPosted Nov 21, 2015, 1:29 AM EST
yes.. we need ref and out to do this
Akash VarshneyPosted Oct 10, 2015, 3:40 AM EDT
No
Ajeet MishraPosted Sep 3, 2015, 5:04 AM EDT
no way. a method will return only one value at a time..
if anybody says more than one value they are absolutely wrong...
a method can't return more than one value at a time
call by value
call by reference
and call by out are the parameter passing mechanisms
that is not called returning a value.
Srinivas PabballaPosted Aug 28, 2015, 1:18 AM EDT
yes
anusha rajuPosted Aug 18, 2015, 5:45 AM EDT
yes
anusha rajuPosted Aug 18, 2015, 5:45 AM EDT
Yes.By using out parameter
Sreeni DonyPosted Jul 22, 2015, 1:20 AM EDT
Yes! A method can return more that one value using out parameter in C#.
Sourabh SomaniPosted Jul 20, 2015, 5:11 AM EDT
yes it is possible but it is not usual.
Joe WilsonPosted Jul 20, 2015, 5:08 AM EDT
Sandeep Banerjee
Can a method Return More than one Value?
Posted by Sandeep Banerjee in C# Programming on Sep 16, 2014
2
10
1422
Do you know the answer for this question? Post it below.
Rahul
Anoop Kumar Sharma
Posted by Anoop Kumar Sharma on Sep 25, 2014
3
Usually Method returns only one value at a time. But in some situation C# Program required to return more than one value from a single method. In Such situation, we have to use Out parameter. Declaring an out parameter in a method is useful when you want a method to return multiple values.
For more visit: http://msdn.microsoft.com/en-us/library/t3c3bfhx.aspx
Kml Surani
Posted by Kml Surani on Apr 15, 2015
0
No, Method Return Only one value
Abrar Ahmad Ansari
Posted by Abrar Ahmad Ansari on Mar 10, 2015
0
Yes you can return more then one value--> use Tuple Concept.
while using below code remove "" quotation from below method return type
class Program
{
public Tuple<"string, int, string> ReturnMorethenOneValue()
{
return new Tuple<"string, int, string>("Abrar Ahmad Ansari", 25, "Bangalore");
}
static void Main(string[] args)
{
var obj = new Program().ReturnMorethenOneValue();
Console.WriteLine("Name :" + obj.Item1);
Console.WriteLine("Age :" + obj.Item2);
Console.WriteLine("Address :" + obj.Item3);
}
}
Pankaj Kumar Choudhary
Posted by Pankaj Kumar Choudhary on Feb 21, 2015
0
Yes,We can do using Out Parameters Like:
static public int Call(out int A1, out int A2, out int A3, out int A4)
{
A1 = 100;
A2 = 200;
A3 = 300;
A4 = 400;
return 500;
}
static void Main(string[] args)
{
int A, B, C, D,E;
E = Call( out A,out B, out C,out D);
Console.WriteLine("A= {0}", A);
Console.WriteLine("B= {0}", B);
Console.WriteLine("C= {0}", C);
Console.WriteLine("D= {0}", D);
Console.WriteLine("E= {0}", E);
Console.ReadKey();
}
Rahul PrajapatPosted Jun 1, 2015, 6:01 PM EDT
Yes you can return more then one value--> use Tuple Concept.
while using below code remove "" quotation from below method return type
class Program
{
public Tuple<"string, int, string> ReturnMorethenOneValue()
{
return new Tuple<"string, int, string>("Abrar Ahmad Ansari", 25, "Bangalore");
}
static void Main(string[] args)
{
var obj = new Program().ReturnMorethenOneValue();
Console.WriteLine("Name :" + obj.Item1);
Console.WriteLine("Age :" + obj.Item2);
Console.WriteLine("Address :" + obj.Item3);
}
}
Abrar Ahmad AnsariPosted Mar 10, 2015, 2:27 AM EDT
Yes,We can do using Out Parameters Like:
static public int Call(out int A1, out int A2, out int A3, out int A4)
{
A1 = 100;
A2 = 200;
A3 = 300;
A4 = 400;
return 500;
}
static void Main(string[] args)
{
int A, B, C, D,E;
E = Call( out A,out B, out C,out D);
Console.WriteLine("A= {0}", A);
Console.WriteLine("B= {0}", B);
Console.WriteLine("C= {0}", C);
Console.WriteLine("D= {0}", D);
Console.WriteLine("E= {0}", E);
Console.ReadKey();
}
Pankaj Kumar ChoudharyPosted Feb 20, 2015, 9:24 PM EST
No.
Pramod VermaPosted Jan 25, 2015, 8:52 AM EST
use OUT parameter for returning multiple values and if the return value are many , than return list of those value .
Friyank ParikhPosted Jan 6, 2015, 6:34 PM EST
No. it's not possible theoretically. we can return multiple value by using collection.
Manish Kumar ChoudharyPosted Nov 17, 2014, 8:28 PM EST
Yes. using yield, we can return multiple values in iteration. Please see http://stackoverflow.com/questions/1407162/what-is-yield-return-in-c .
Dhanik SahniPosted Oct 9, 2014, 5:26 AM EDT
yes
http://www.dotnetperls.com/multiple-return-values
Munesh SharmaPosted Sep 30, 2014, 10:03 PM EDT
Usually Method returns only one value at a time. But in some situation C# Program required to return more than one value from a single method. In Such situation, we have to use Out parameter. Declaring an out parameter in a method is useful when you want a method to return multiple values.
For more visit: http://msdn.microsoft.com/en-us/library/t3c3bfhx.aspx
Anoop Kumar SharmaPosted Sep 24, 2014, 8:55 PM EDT
The answer is no a method is limited to returning just a single return value. However, it is possible to return an Array. An Array is a data structure that is actually a collection of Same variable.
Sandeep BanerjeePosted Sep 16, 2014, 4:28 AM EDT















