#

WE ARE SHARING

OUR EXPERIANCE.

BELIEVE THE POWER OF SHARE

BLOG

C# 7 de Tuple

C# 7 de Tuple

C# 7.0 introduced ValueTuple structure, which is a value type representation of the tuple object. The language team made many good things for this value tuple type, including a new syntax and many features (such as deconstruction.)

The following is a rewrite version with the value tuples, Note that if you don’t see the ValueTuple available in your project, you have to download the System.ValueTuple 4.3.0 NuGet package to your project. You don’t need to do anything if you are using .NET Framework 4.7 or higher, or .NET Standard Library 2.0 or higher.



public static (double, double, double, double) CokluIslem(double Sayi1,double Sayi2)
{
   double ToplamSonucu=Sayi1+Sayi2; 
double CarpmaSonucu=Sayi1*Sayi2;
double FarkSonucu=Sayi1-Sayi2;
double BolmeSonucu=Sayi1/Sayi2;
return (ToplamSonucu,FarkSonucu,CarpmaSonucu,BolmeSonucu) ;
}
public static Main(string[] args) { 
    var (toplam,fark,carpma,bolme)= CokluIslem(190, 7);
   Console.WriteLine(toplam); 
Console.WriteLine(fark);
Console.WriteLine(carpma);
   Console.WriteLine(bolme);
}

Output:

  197

  183

  1330

   27,1428571428571

Source; https://blogs.msdn.microsoft.com/mazhou/2017/05/26/c-7-series-part-1-value-tuples/