title: C# Vector2 code
body: <p>I needed a Vector2 struct for a project and I am not very strong with math, this class seems to be working but I would greatly appreciate any pointers on how to I could optimize the code or if I have made any errors. 
  Also is there a cheaper way to do distance calculation than Math.Sqrt?</p>
  
  <pre><code>    private struct Vector2
      {
          public float X;
          public float Y;
  
          public Vector2(float x, float y)
          {
              this.X = x;
              this.Y = y;
          }
  
          public static Vector2 operator +(Vector2 v1, Vector2 v2)
          {
              return new Vector2(v1.X + v2.X, v1.Y + v2.Y);
          }
  
          public static Vector2 operator -(Vector2 v1, Vector2 v2)
          {
              return new Vector2(v1.X - v2.X, v1.Y - v2.Y);
          }
  
          public static Vector2 operator *(Vector2 v1, float m)
          {
              return new Vector2(v1.X * m, v1.Y * m);
          }
  
          public static float operator *(Vector2 v1, Vector2 v2)
          {
              return v1.X * v2.X + v1.Y * v2.Y;
          }
  
          public static Vector2 operator /(Vector2 v1, float m)
          {
              return new Vector2(v1.X / m, v1.Y / m);
          }
  
          public static float Distance(Vector2 v1, Vector2 v2)
          {
              return (float)Math.Sqrt(Math.Pow(v1.X - v2.X, 2) + Math.Pow(v1.Y - v2.Y, 2));
          }
  
          public float Length()
          {
              return (float)Math.Sqrt(X * X + Y * Y);
          }
      }
  </code></pre>