What is the meaning of Tuple (Of T)

Possible duplicate:
What is the purpose of Tuple (T1) / Singleton in .net?

Trying to simulate a tuple implemented in .Net 4 (for .Net 3), I just realized that there is Tuple (Of T)? It was quite unexpected!

Why would anyone do this

Tuple<string> result = new Tuple<string>("Data"); 

Instead of this

 return "Data"; 

Isn’t the whole point of the tuple that its container is for "loosely coupled data that is not cohesive enough to make another class"? Did I miss something?

+7
source share
2 answers

There are a finite number of tuples in the library, so to define an 8-tuple, you use a view with 7 elements, the "rest" argument is one tuple. Cm

http://msdn.microsoft.com/en-us/library/dd383325.aspx

+4
source

This is a transfer from set theory, which may not make much sense to a software developer.

Tuples are simply ordered lists of elements. An N-tuple has n elements, and n can be one, which is called a singleton. You probably won't have much use for a code with 1 tuple, but I assume the C # team put it there for completeness.

http://en.wikipedia.org/wiki/Tuple#Etymology

+1
source

All Articles