

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
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
- Related Questions & Answers
- C++ Program to Access Elements of an Array Using Pointer
- Java Program to Access elements from a LinkedList
- How to access elements from jagged array in C#?
- How to access elements from an array in C#?
- How to access elements from multi-dimensional array in C#?
- How to access elements from a rectangular array in C#?
- How to access array elements using a pointer in C#?
- Access front and rear element of Python tuple
- How to access HTML elements in JavaScript?
- Raise elements of tuple as power to another tuple in Python
- Delete Tuple Elements in Python
- How to append elements in Python tuple?
- How to get the remaining elements of the Tuple in C#?
- C# Program to access first element in a Dictionary
- How to access elements of an array using pointer notation in C#?
Advertisements