User Tools

Site Tools


tuples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
tuples [2018/02/06 06:31] wolfgangriedmanntuples [2018/02/10 08:28] (current) wolfgangriedmann
Line 3: Line 3:
 The [[https://docs.microsoft.com/en-us/dotnet/api/system.tuple|System.Tuple]] class can be used to hold different objects, it is like a list with predefined data. The [[https://docs.microsoft.com/en-us/dotnet/api/system.tuple|System.Tuple]] class can be used to hold different objects, it is like a list with predefined data.
  
-A tuple is very useful when you need fixed groups of data and don't like to define a own class for it.+A tuple is very useful when you need fixed groups of data and don't like to define a own class for it. To define and to create a tuple you need generics. 
 +<code>local oTuple as Tuple<int,string> 
 +  
 +oTuple := Tuple<int,string>{ 123, "Hello World!"
 +Console.WriteLine( oTuple:Item1:ToString() ) // 123 
 +Console.WriteLine( oTuple:Item2 )            // Hello World! 
 +Console.WriteLine( oTuple:Item1:GetType():Name ) // Int32 
 +Console.WriteLine( oTuple:Item2:GetType():Name ) // String</code> 
 + 
 +Please see also the following X# forum post: [[https://www.xsharp.info/forum/pearls/251-tuples-getting-more-for-your-money|Pearls: Tuples: getting more for your money]] 
  
tuples.txt · Last modified: 2018/02/10 08:28 by wolfgangriedmann