- 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
C# Program to access tuple elements
Create a tuple.
var myTuple = Tuple.Create(1, 2.5M, "Amit", "100");
Now to access tuple elements, use the properties.
To access first element.
myTuple.Item1
To access second element.
myTuple.Item2
In the same way, for other elements, use the properties as shown below −
Example
using System; public class Program { public static void Main() { var myTuple = Tuple.Create(1, 2.5M, "Amit", "100"); Console.WriteLine("Item1 : "+ myTuple.Item1); Console.WriteLine("Item2 : "+ myTuple.Item2); Console.WriteLine("Item3 : "+ myTuple.Item3); Console.WriteLine("Item4 : "+ myTuple.Item4); } }
Output
Item1 : 1 Item2 : 2.5 Item3 : Amit Item4 : 100
Advertisements