C
C#2y ago
0_00

Classes question in c#

what does the
public Point(int x, int y) => (X, Y) = (x, y);
public Point(int x, int y) => (X, Y) = (x, y);
do in the code features on microsofts site
3 Replies
Jimmacle
Jimmacle2y ago
they're using tuples for what looks like the sole purpose of making the constructor a one-liner: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/value-tuples
Tuple types - C# reference
Learn about C# tuples: lightweight data structures that you can use to group loosely related data elements
Jimmacle
Jimmacle2y ago
so it's practically the same as
public Point(int x, int y)
{
X = x;
Y = y;
}
public Point(int x, int y)
{
X = x;
Y = y;
}
0_00
0_002y ago
oh ok thanks