Home > Blockchain >  What is this data type in c#?
What is this data type in c#?

Time:12-09

I noticed this data type of (local variable) (double freq, double power)[] named freqvsPower

What does this mean? This isn't a 2D array, it seems to be an array of two types...

CodePudding user response:

This is a enter image description here

what you are noticing is syntactic sugar for ValueTuple

var vTuple0 = ValueTuple.Create(1d, 1d);//valuetuple object creation
ValueTuple<double,double> vTouple2 = new ValueTuple<double,double>(1,1);//valuetuple object
(double freq, double power) vTouple = (1, 1);//again valuetuple object - syntactic sugar
//above 3 declarations mean the same

//values from tuple can be access with Item1, Item2....so on
Console.WriteLine(vTouple.Item1);
  •  Tags:  
  • c#
  • Related