C# 7 Tuple Improvement

Introduction

As you all know, there are a number of ways to return more than one data type from a function in C#. I am going to explain how to return multiple values from a C# function using a Tuple.

Before I jump into Tuple improvement, let's try to understand how this works prior to C# 7.0 with a small example.

Let us create a class named Calculator. This class has got one method named GetAritmenticOpeartionsPriorCsharp7 which accepts two integer parameters. This function will return the sum and multiplied values of the supplied inputs.


The function GetAritmenticOpeartionsPriorCsharp7 returns two integer values. The first value is the sum of inputs and the second value is the multiplication of supplied inputs.

Now let's call this method from a console application, as shown below.


Let's run this application and find out the output.