This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// declare and assign | |
(float x, float y) = GetPosition(); | |
// just assign | |
float x, y; // declare variables elsewhere | |
(x, y) = GetPosition(); | |
// tuple usage (explicit) | |
ValueTuple<float, float> ret = GetPosition(); | |
float x = ret.Item1, y = ret.Item2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float x, y; | |
public ValueTuple<float, float> GetPosition() { | |
return ValueTuple.Create(_x, _y); | |
} | |
// Is exactly the same as GetPosition above | |
public (float, float) GetPositionAlternateSyntax() { | |
return (_x, _y); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public struct Vector2 { | |
public float x; | |
public float y; | |
public Vector2(float x, float y) { | |
this.x = x; | |
this.y = y; | |
} | |
} |
NewerOlder