dot NET Framework 4.0 Tuples

Information about dot NET Framework 4.0 Tuples

Published on June 16, 2016

Author: ameyrocks01

Source: authorstream.com

Content

Slide1: Visit: http://crbtech.in/Dot-Net-Training/ Tuple is an inbuilt class sort presented in .net system 4.0. This article is extremely valuable if the developer knows when and where to utilize it. A tuple in .net system 4.0 will relinquish to an information structure whose component can be classified specifically. Tuple Insight A Tuple is a static class and can be infused with a rundown of things that are of various sorts. A tuple article can be made utilizing its constructor or by utilizing the technique plant strategy called Create. Following below are the code tests - //Using the Generic constructor var t = new Tuple<int, int, string, DateTime>(10, 25, "This is a tuple demo", DateTime.Now); //Using the factory method Create var t1 = Tuple.Create<int, int, string, DateTime>(10, 25, "This is a tuple demo", DateTime.Now); Slide2: Visit: http://crbtech.in/Dot-Net-Training/ Following below is the code showing it - //Nesting tuples var t = new Tuple<int, int>(10, 25); var t1 = new Tuple<string, int, int, int, int, int, int, Tuple<int, int>>("This is a tuple demo", 1, 2, 3, 4, 5, 6, t); Getting to the Data from a Tuple Object The information values provided to the tuple articles will be uncovered as Item1, Item2, and so forth. Slide3: Visit: http://crbtech.in/Dot-Net-Training/ Following below is the code showing how to get the information from the tuple object: class Program { static void Main(string[] args) { var t = GetEmployeeTupleObject(); Console.WriteLine("Name: {0} {1}", t.Item1, t.Item2); Console.WriteLine("Age: {0}", t.Item3); Console.WriteLine("Job Title: {0}", t.Item4); } private static Tuple<string, string, int, string> GetEmployeeTupleObject() { return new Tuple<string, string, int, string>("John", "Britto", 32, "Senior Developer"); } } Slide4: Visit: http://crbtech.in/Dot-Net-Training/ The benefits of Using a Tuple in .NET Program This segment gets a walkthrough from the favorable benefits of utilizing a tuple object as a part of .net. 1. For a strategy to give back numerous qualities preceding .net system 4.0 is to proclaim the out parameters and bring the information through it. Yet, with the utilization of tuple the designer can send back various information things without utilizing the outer parameter. 2. Numerous parameters can be clubbed into a single tuple and go on as a single parameter to the strategy. Later in the technique, the qualities can be brought by utilizing the tuple's thing properties. 3. Tuple information is specifically firmly typed so that there is no boxing or unpacking required. This enhances the execution of the .net system. Slide5: Visit: http://crbtech.in/Dot-Net-Training/ 4. On the off chance that you need to pass a worker subtle element from a capacity as appeared in the over segment's specimen code in the prior .net structure forms you may need to make an Employee class or a struct and afterward populate the information. Be that as it may, by utilizing the tuple object you have accomplished it in a specific way effortlessly and with diminished lines of code. 5. You can build the capacity limit of the tuple object by making settled Tuples. The size is not a major limitation as the Tuple is a reference sort yet with a struct this is a genuine issue as the struct is a quality sort and will be put away on the stack. 6. As I said Tuple is a reference sort you can perform and analyze operations like other reference sorts. Slide6: Visit: http://crbtech.in/Dot-Net-Training/ class Program { static void Main(string[] args) { var t = GetEmployeeTupleObject(); var t1 = GetEmployeeTupleObject(); //Compares the data value, TRUE Console.WriteLine(t.Equals(t1)); //Compares the address of the object, FALSE Console.WriteLine(t == t1); } private static Tuple<string, string, int, string> GetEmployeeTupleObject() { return new Tuple<string, string, int, string>("John", "Britto", 32, "Senior Developer"); } } Slide7: Visit: http://crbtech.in/Dot-Net-Training/ A few Limitations 1. In the event that you contrast a Tuple object and a custom article employee the tuple does not have the qualities mapped against all around named properties like FirstName, LastName, Age, JobTitle, and so on.; rather it uncovered them as Item1, Item2, Item3, and Item4. So when a tuple article is passed to an outside class then the calling class ought to know in what grouping the qualities are being passed. 2. Since the Tuple class does not actualize an IEnumerable class you can't verifiably utilize it in a ForEach circle. On the off chance that you need to utilize ForEach still then make a custom class acquiring Tuple and Ienumerable. Slide8: Visit: http://crbtech.in/Dot-Net-Training/ Related Articles : .NET 4 features An Overview of Microsoft MVC Dot Net Slide9: Visit: http://crbtech.in/Dot-Net-Training/

Related presentations


Other presentations created by ameyrocks01

ASP.NET TO MVC 3  TO  MIGRATION
14. 06. 2016
0 views

ASP.NET TO MVC 3 TO MIGRATION

ASP.NET-4.5-Architecture
31. 05. 2016
0 views

ASP.NET-4.5-Architecture

ASP.NET life cycle in depth
01. 06. 2016
0 views

ASP.NET life cycle in depth

phpvsaspdotnet
13. 06. 2016
0 views

phpvsaspdotnet

php-vs-asp-dot-net
13. 06. 2016
0 views

php-vs-asp-dot-net

ASP.NET TO MVC 3 MIGRATION
14. 06. 2016
0 views

ASP.NET TO MVC 3 MIGRATION

WHAT MAKES .NET INTERESTING
22. 06. 2016
0 views

WHAT MAKES .NET INTERESTING

BLACK HOLE IS ASP DOT NET
30. 06. 2016
0 views

BLACK HOLE IS ASP DOT NET

BLACK HOLE IN ASP DOT NET
30. 06. 2016
0 views

BLACK HOLE IN ASP DOT NET