public
Created

Not sure what this is called, anonymous tuple?

  • Download Gist
anonTuple.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// I want to be able to do this in C#
 
int a = 4;
int b = 2;
 
(a, b) = (b, a); // swap values
 
// ... and used in some terribly named methods...
 
public void AssignValues()
{
var (id, name) = GetValues();
// more statements
}
 
public int, string GetValues()
{
return (123, "gist");
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.