HI why do we use get/ set to change properties?
I mean instead of writing
class Point {
double x, y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public double X {
get { return x; }
set { x = value; }
}
public double Y {
get { return y; }
set { y = value; }
}
}
cant we write simply,
supposse for eg,
x=5.0;
y=x;
please explain why do we need to use this get/set methoss?