C
C#

help

Classes question in c#

0_003/13/2023
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
JJimmacle3/13/2023
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
JJimmacle3/13/2023
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_003/13/2023
oh ok thanks

Looking for more? Join the community!