In this article, let's discuss on Tuple Class in C# and the potential new proposals that are being considered for C#7. Potential Features - Tuple What is Tuple in C#? Basically, a tuple ( Tuple in C# ) is an ordered sequence, immutable, fixed-size and of heterogeneous objects, i.e., each object being of a specific type. The tuples are not new in programming. They are already used in F#, Python, and databases. A tuple allows you to combine multiple values of possibly different types into a single object without having to create a custom class. This can be useful if you want to write a method that for example returns three related values but you don’t want to create a new class. System.Tuples namespace supports Tuple class in C#. The purpose of a tuple is to create a way to return multiple values from a function. class CodeYourWayTupleDemo { static void Main() { // Create three-item tuple. Tuple tuple = new Tuple ...
Comments
Post a Comment