IDG Contributor Network: How to work with a Tuple in C#

5 months ago Comments Off on IDG Contributor Network: How to work with a Tuple in C#

Tuples are nothing new – they have been around for quite some time now in programming languages like F#, Python, etc. and also in databases. A Tuple maybe be defined as a data structure that comprises of an ordered, finite sequence of immutable, heterogeneous elements that are of fixed sizes. Elements in a Tuple are immutable, i.e., they pertain to a specific type. You can take advantage of tuples to return multiple values from a method and also create composite collections. You can leverage the static methods of the System.Tuple class to work with tuples in .Net.

What is a Tuple?

Tuple is a data structure that comprises of an ordered, heterogeneous collection of “n” elements — the elements in a tuple can either be of the same type or even be of dissimilar types. In Mathematics, an n-tuple maybe defined as a sequence or as an ordered list of “n” elements. It should be noted that “n” here denotes a positive integer. Further, there can be only one 0-tuple, i.e., an empty sequence.

To read this article in full or to leave a comment, please click here

InfoWorld