- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Tuple Class in C#
If you want to return more than one value from a class method, then use C# Tuples. To create tuples in C#< this class provides a static method. Tuples introduced in .NET 4.0.
Example
Let us now see an example to implement Tuple in C# −
using System; public class Demo { public static void Main(string[] args) { Tuple<int, string> tuple = new Tuple<int, string>(2, "Tom"); if (tuple.Item1 == 150) { Console.WriteLine(tuple.Item1); } if (tuple.Item2 == "Tom") { Console.WriteLine(tuple.Item2); } } }
Output
This will produce the following output −
Tom
Advertisements