How to returns multiple values from a method using tuple in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static Tuple<string, int, char> MultiVal()
        {
            return new Tuple<string, int, char>("csharp", 87, 'z');
        }
        static void Main(string[] args)
        {
            var result = MultiVal();

            string s = result.Item1;
            int n = result.Item2;
            char ch = result.Item3;

            Console.WriteLine(s);
            Console.WriteLine(n);
            Console.WriteLine(ch);
        }
    }
}


/*
run:
   
csharp
87
z
 
*/

 



answered Aug 21, 2018 by avibootz

Related questions

2 answers 188 views
1 answer 163 views
3 answers 347 views
2 answers 212 views
1 answer 135 views
...