Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Return a C# tuple from a method
Firstly, create a tuple as shown below that calls a method.
var tuple = Show();
The above statement calls the following method −
static Tuple<int, int, int, int, int> Show()
Under the method, return the tuple as shown below −
Example
using System;
public class Demo {
public static void Main() {
var tuple = Show();
Console.WriteLine(tuple.Item1);
Console.WriteLine(tuple.Item2);
Console.WriteLine(tuple.Item3);
Console.WriteLine(tuple.Item4);
Console.WriteLine(tuple.Item5);
}
static Tuple<int, int, int, int, int> Show() {
return Tuple.Create(3, 5, 7, 9, 11);
}
}
Output
3 5 7 9 11
Advertisements