Answers for "tuple initialization c#"

C#
3

c# initialize tuple with default values

(double, int) t1 = (4.5, 3);
Console.WriteLine($"Tuple with elements {t1.Item1} and {t1.Item2}.");
// Output:
// Tuple with elements 4.5 and 3.

(double Sum, int Count) t2 = (4.5, 3);
Console.WriteLine($"Sum of {t2.Count} elements is {t2.Sum}.");
// Output:
// Sum of 3 elements is 4.5.
Posted by: Guest on July-30-2020
0

c# initialize tuple

var person = (1, "Bill", "Gates");
    
//equivalent Tuple
//var person = Tuple.Create(1, "Bill", "Gates");
Posted by: Guest on January-21-2021

C# Answers by Framework

Browse Popular Code Answers by Language