TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
48
11.9k
Passing a ValueTuple return type as an argument.
Oct 15 2019 12:34 PM
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!
Reply
Answers (
2
)
C# automation testing
Create a program named FortuneTeller