Powered by Blogger.

Sunday, February 23, 2014

Tutorial on Tuple in C#.Net 4.0

In this post we will discuss about Tuple in C#.Net 4.0. Also you can check out:

- Create datatable at runtime in Asp.Net

- Logging In Users Programmatically in Asp.Net

- How to implement FileUpload Control in Update Panel using asp.net?

- There are some new features in .Net 4.0, one of these is Tuple.

- Tuple actually a concept of F#, But in .Net 4.0 microsoft introduced Tuples to .Net.

- Arrays combine objects of the same type; tuples can combine objects of different types.

- .NET 4 defines eight generic Tuple classes and one static Tuple class.

- Tuple can be instantiated by Tuple constructor or the static Tuple.Create() method.

- Tuple.Create method has 8 overloads.

Here is an example that is provided in msdn:
var population = new Tuple<string, int, int, int, int, int, int>(
                           "New York", 7891957, 7781984,
                           7894862, 7071639, 7322564, 8008278);


Tuple<int, string> tuple = new Tuple<int, string>(1, "aspdotnethelp");