1

Let's say I have a dictionary with points. So I could then write:

if (dict.TryGetValue(key,out (double x,double y) point))
  point.x ...

But how do get rid of point and unpack the elements of the tuple right away? I have something like this in mind:

if (dict.TryGetValue(key,out (out double x,out double y)))
  x ...
greenoldman
  • 16,895
  • 26
  • 119
  • 185

1 Answers1

2

It seems currently it is not possible based on this opened issue.

In terms of deconstructing the best option, I think, you have is to do it in two steps:

if (dict.TryGetValue(key, out var point))
{
    (double x, double y) = point;
    ...
}
Guru Stron
  • 102,774
  • 10
  • 95
  • 132