I'm wondering how to make my custom user type able to be added and subtracted from the same types. For example:
public class CustomType {
public float x;
public float y;
public CustomType(float x, float y) {
this.x = x;
this.y = y; } }
public class test : Form {
CustomType r = new CustomType(3, 5);
private void Form1_Load(object sender, EventArgs e) {
MessageBox.Show(r.ToString() + " squared is: " + Square(r).ToString()); }
public CustomType Square(CustomType type) {
return type * type; } }
As you all know this will have a single syntax error which is simply that the operator '*' can't be applied to operands of 'CustomType' and 'CustomType'. So I simply want some information on how I can achieve this with my custom types like XNA Framework's Vector2 class. I can multiply it, subtract it, add it, and divide it with by it's own type. So any information would be helpful.
Thanks,
Jamie