title: C# - How can I modify a struct given by a getter?
body: <p>I'm quite new to C# and I'm still figuring things out.
  My problem is that I've got a class like this:</p>
  
  <pre><code>class Sprite {
      private Vector3 _position;
  
      public Vector3 Position {
          get { return _position; }
          set { _position = value;
                HandleEvent(); }
      }
  
      public Sprite() {
          _position = new Vector3();
      }
  }
  </code></pre>
  
  <p>With a Vector3 object and a get/set block.
  Here is a simplified version of the Vector3 struct:</p>
  
  <pre><code>struct Vector3 {
      float X, Y, Z;
  }
  </code></pre>
  
  <p>Now my problem is that if I do this:</p>
  
  <pre><code>Sprite sprite = new Sprite();
  sprite.Position.X += 4.0F;
  </code></pre>
  
  <p>It gives me an error because Position is not a variable but given to me by a getter. But I don't want to make _position public, because I want to handle an event when the variable is changed.</p>
  
  <p>(In Java this works perfectly, that's why I'm confused :/)</p>
  
  <p>Could you give me a hint what I'm doing wrong or what you would do differently?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Yes, Vector3 is a struct and not a class. Sorry for the confusion, but I'm pretty new to C#.</p>