User Tools

Site Tools


tuples

System.Tuple

The 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. To define and to create a tuple you need generics.

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

Please see also the following X# forum post: Pearls: Tuples: getting more for your money

tuples.txt · Last modified: 2018/02/10 08:28 by wolfgangriedmann