0

I'm wondering if it's possible to create an implicit conversion extension to convert from a tuple of floats to a System.Numerics.Vector2 so that I can do something like this to create a Vector2:

Vector2 vector = (0.5f, 0.7f);

I've tried doing this

public static implicit operator Vector2(this (float x, float y) v) => new Vector2(v.x, v.y);

but it doesn't seem like the this keyword works with a tuple.

It isn't important for me that this works it would just be nice if it did.

Edit:

Found my answer: Can I add an implicit conversion for two classes which I don't directly control? Don't know how I didn't find it the first time I was searching.

FireSquid
  • 86
  • 5

0 Answers0