Interviews - C# Corner

Gajendra Jangid
Is it possible that a method can return multiple value at a time?
By Gajendra Jangid in .NET onJan 31 2018
  • Naresh Singhal
    Feb, 2018 5

    Yes , you can return multiple values in a single method using TUPLE

    • 5
  • Md Shahnawaz
    Feb, 2018 21

    Yes ,You can return multiple values in a single method using ref/out keywords

    • 4
  • Gajendra Jangid
    Jan, 2018 31

    No it is not. You can return an object though and that object can contain multiple properties –

    • 2
  • Sandeep Kumar
    Feb, 2018 28

    Yes it is possible by using TUPLE.

    • 1
  • Sathiya Moorthy
    Feb, 2018 18

    Yes. Simplest way is to use 'Tuple'. Which was introduced in C# 4.0Prior 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

    • 1
  • Tushar Dikshit
    Feb, 2018 13

    You can achieve with a workaround. By definition method return one value. # You can use out parameter and Tuples. The newly introduced in c#.

    • 1
  • SAUMYA TIWARI
    Feb, 2018 9

    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; }

    • 1
  • Ishoo Anyal
    Sep, 2019 27

    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

    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS