Is it possible to deconstruct ValueTuple parameters?

Is it possible to deconstruct a tuple that does not return from the method but is an out parameter? I'm not sure that I am expressing or even using the correct terms correctly, so here are a few examples:

void OutMethod(out (int aNumber, string someText) output) => output = (15, "yo"); void Usage() { { // Works, of course. OutMethod(out var tuple); // But *slightly* aesthetically unappealing to use. var usage = $"{tuple.someText}: {tuple.aNumber}"; } { // Would be awesome, but doesn't work. OutFunction(out var(number, text)); } { // Would be awesome too, but doesn't work. OutFunction(out (var number, var text)); } { // This doesn't work either. OutFunction((out var number, out var text)); } { // Not even this. OutFunction((out int number, out string text)); } { // Or this. OutMethod(out (int number, string text)); } { // Or this. int number; string text; OutMethod(out (number, text)); } } 

By the way, I’m not complaining. Just wondering if I'm missing something.

+5
source share
1 answer

This is currently not possible. Further, according to this comment by CSharplang github repo :

This was what we took at the LDM [Language Design Meetings] when we were triaging and decided not to, at least in the near future ...

So he is likely to remain "impossible" for some time.

+6
source

Source: https://habr.com/ru/post/1274099/


All Articles