title: C#: How to handle accessing of a property of a computed public get/set accessor
body: <p>Sorry for the long question! I've been trying my hand at using get/set accessors, but I've run into a problem.  </p>
  
  <p>To give an example, I have a Vector2D class which has private double x and y values and public accessors X and Y for those values. I also have a public Direction property (of a custom type Angle which itself has public double Degrees and Radians properties). This Direction property has a <em>get</em> accessor which returns a new Angle object based on the values of X and Y, and a <em>set</em> accessor which changes the X and Y values based on the new Angle value passed in.</p>
  
  <p>So if you have a Vector2D called vector you can use vector.Direction = new Angle(0), which works fine. But naturally it's also possible to write vector.Direction.Degrees = 0. This doesn't cause errors but it also doesn't work as intended, since the x and y values of the vector aren't updated.</p>
  
  <p>After thinking about it I understand <em>why</em> this happens. When you write vector.Direction.Degrees, it uses the <em>get</em> accessor in Vector2D, which returns a new Angle based on X and Y, and then it accesses the Degrees property and its <em>set</em> accessor on <em>that</em> object, not the <em>set</em> accessor for the Direction property on the original vector object. In other words, the <em>set</em> accessor on vector.Direction doesn't get used in that scenario at all, and so the x and y values aren't updated. And that makes sense I suppose.</p>
  
  <p>It's clearly confusing that you can access vector.Direction.Degrees and attempt to set it to a different value yet this doesn't actually do anything. But I also see that this behaviour is intended. My question is, what is a good way to deal with this problem?</p>
  
  <p>Thanks in advance!</p>
  
  <p>EDIT - Here's the relevant part of my class definition:</p>
  
  <p><strong>Vector2D class</strong></p>
  
  <pre><code>    private double x;
      private double y;
  
      public double X { get =&gt; x; set =&gt; x = value; }
      public double Y { get =&gt; y; set =&gt; y = value; }
  
      public Angle Direction
      {
          get
          {
              return new Angle(X, Y);
          }
          set
          {
              double previousMagnitude = Magnitude;
  
              X = Math.Cos(value.Radians) * previousMagnitude;
              Y = Math.Sin(value.Radians) * previousMagnitude;
          }
      }
  </code></pre>