Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C# program to create a ValueType with names
With C# 7, you can easily create a ValueType with names.
Note − Add System.ValueTuple package to run ValueTuple program.
Let’s see how to add it −
- Go to your project
- Right click on the project in the solution explorer
- Select “Manage NuGet Packages”
- You will reach the NuGet Package Manager.
- Now, click the Browse tab and find “ValueTuple”
- Finally, add System.ValueTuple package
Example
using System;
class Program {
static void Main() {
var myTuple = (marks: 95, name: "jack", subject: "maths");
//Add System.ValueTuple package to run this program
// using names to access
Console.WriteLine("Student Marks: "+myTuple.marks);
Console.WriteLine("Student Name: "+myTuple.name);
Console.WriteLine("Student Subject: "+myTuple.subject);
}
}
Output
Student Marks: 95 Student Name: Jack Student Subject: Maths
Advertisements
