title: How can I use an array-initializer syntax for a custom vector class?
body: <p>I have a class <strong>roughly</strong> designed as such:</p>
  
  <pre><code>class Vector3
  {
      float X;
      float Y;
      float Z;
  
      public Vector3(float x, float y, float z)
      {
          this.X = x;
          this.Y = y;
          this.Z = z;
      }
  }
  </code></pre>
  
  <p>I have other classes implementing it as properties, for example:</p>
  
  <pre><code>class Entity
  {
      Vector3 Position { get; set; }
  }
  </code></pre>
  
  <p>Now to set an entity's position, I use the following:</p>
  
  <pre><code>myEntity.Position = new Vector3(6, 0, 9);
  </code></pre>
  
  <p>I would like to shorten this up for the user by implementing an array-like initializer for Vector3:</p>
  
  <pre><code>myEntity.Position = { 6, 0, 9 };
  </code></pre>
  
  <p>However, no class can inherit arrays. Moreover, I know I could somehow manage to get this with minor hacks:</p>
  
  <pre><code>myEntity.Position = new[] { 6, 0, 9 };
  </code></pre>
  
  <p>But this is not the point here. :)</p>
  
  <p>Thanks!</p>