Values are immutable. Variables that contain value types are mutable. Variables change, so they are called "variables."
, , , .
struct Point { public int X; public int Y; public int Z; }
...
Point p = new Point();
p.X = 123;
, , " p". . p , - . p, , . .
:
struct Point { public int X { get; private set; } ... etc }
!
Point p = new Point(123, 456, 789);
p = new Point(100, 200, 300);
, , , .
:
static Point Translate(Point p, int offset)
{
return new Point(p.X + offset, p.Y + offset, p.Z + offset);
}
...
Point p = new Point(100, 200, 300);
p = Translate(p, 5);
., , p , , .