I am interested in retrieving a tuple of multiple values from a class method and then passing that result directly to another class method. See example code to see what I intend (it does not compile):
Edit: I realize that I could use "(double, double) myVar" as the parameter and then use myVar.Item1, and myVar.Item2, but I would prefer to be able to use the terms that I define and not something so generic.
- class ClassA
- {
- public static (double, double) GetTuple()
- {
- return (12.5, 13.5);
- }
- }
-
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- ClassB.ShowTuple(ClassA.GetTuple());
- }
- }
-
- public static class ClassB
- {
- public static void ShowTuple((double myVar1, double myVar2))
- {
- Console.WriteLine(myVar1);
- Console.WriteLine(myVar2);
- }
- }
The problem appears to be in ClassB with the parameter passed to ShowTuple. I tried it without the extra parenthesis, as a Tuple, ValueTuple, etc., but nothing seems to work.
Does anyone know what I am missing?
Thanks!