One of the Tuple Types in .net 4 is a Single-Element Tuple. I just wonder what the purpose of this struct is?
The only use I saw is when using in the 8+ Tuple as it can be assigned to TRest, where it actually makes sense. Is that it? Or is there any other purpose?
You’d have to ask the BCL designers to be certain, but I suspect that since there is a 1-tuples in the real world, the .NET framework authors wanted to provide equivalent symmetry in their implementation.
Tuplesare the .NET implementation of what you’d consider the mathematical concept of a tuple.Now since you’re asking for programming uses for
Tuple<T>, I would also answer that there are .NET languages (like F#) that could useTuple<>for representation of things like return values from functions. Since an F# function could certainly return a 1-tuple as a result – it adds symmetry and consistency to the behavior and feel of the language.Your example with 8+ tuples is also probably legitimate, in that the
Restproperty could be a 1-tuple to represent the “overflow”.