Cześć wszystkim. Czy modyfikacja wartości pól obiektu w stylu pkt.x = np. 50 jest poprawną praktyką?
public struct Punkt
{
private int _x;
private int _y;
public Punkt(int x, int y)
{
_x = x;
_y = y;
}
public int x
{
get
{
return _x;
}
set
{
_x = value;
}
}
public int y
{
get
{
return _y;
}
set
{
_y = value;
}
}
}
class Program
{
static void Main(string[] args)
{
Punkt pkt = new Punkt(20, 30);
Console.WriteLine(pkt.x);
pkt.x = 50;
Console.WriteLine(pkt.x);
}
}