Consider the following code.
using System.Drawing;
public class Element
{
public static Point position1;
private static Point position2;
public static Point Position2
{
get { return position; }
set { position = value; }
}
}
class Drawing
{
public Drawing()
{
Element.position1.X = 0; //Correct
Element.Position2.X = 0; //Incorrect
}
}
Why can not the value of position2.X
be changed through Element.Position2.X
?
Because of this I am obliged to do :
Point newPoint = new Point (0, 0);
Element.Position2 = newPoint;
//Or : Element.Position2 = new Point (0, Element.Position2.Y);
- Why is not it simply possible to access the value of
position2.X
as withposition1.X
but usingElement.Position2.X
? - Do you know any other way to solve the problem?