In this article we are going to see a concept called Tuple, which is present in the dotnet framework 4.0, why Tuple is there in framework, what is the usage of the That ? Tuple is a data structure to store the identifiers, The Tuple is stored in a separated location of a memory.Once we create the Tuple, it can be be changed.
Tuple:
Example:
Output:
Number:- 1, Name:- Rajesh, Employee Department:- Technical
From this article you can learn how to use the Tuple.
Tuple:
Create<T1>(T1) | |
1 | Create<T1, T2>(T1, T2) |
2 | Create<T1, T2, T3>(T1, T2, T3) |
3 | Create<T1, T2, T3, T4>(T1, T2, T3, T4) |
4 | Create<T1, T2, T3, T4, T5>(T1, T2, T3, T4, T5) |
5 | Create<T1, T2, T3, T4, T5, T6>(T1, T2, T3, T4, T5, T6) |
6 | Create<T1, T2, T3, T4, T5, T6, T7>(T1, T2, T3, T4, T5, T6, T7) |
7 | Create<T1, T2, T3, T4, T5, T6, T7, T8>(T1, T2, T3, T4, T5, T6, T7, T8) |
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Employee
{
public string EmpId {
get; set; }
public string Address
{ get; set; }
public int
PhoneNumber { get; set;
}
public string
Department { get; set;
}
public string EmpName
{ get; set; }
}
class Program
{
static void Main(string[] args)
{
var Company = Tuple.Create<int, string, string, Employee>(1,
"Rajesh", "Chennai",
new Employee()
{ EmpId = "E1", EmpName = "Rajesh . G", Department = "Technical", PhoneNumber = 1233444,
Address = "chennai" });
Console.WriteLine("Number:-
{0}, Name:- {1}, Employee Department:- {2}",
Company.Item1.ToString(), Company.Item2, Company.Item4.Department);
Console.Read();
}
}
}
Output:
Number:- 1, Name:- Rajesh, Employee Department:- Technical
From this article you can learn how to use the Tuple.
No comments:
Post a Comment