I keep getting a stack overflow, yet this is how System.String is setup.Code:class test { public int i = 0; static bool EqualsHelper(test a, test b) { return (a.i == b.i); } static bool Equals(test a, test b) { return ((a == b) || (((a != null) && (b != null)) && EqualsHelper(a, b))); } public static bool operator !=(test a, test b) { return !Equals(a, b); } public static bool operator ==(test a, test b) { return Equals(a, b); } public test(int a) { i = a; } } private void Form1_Load(object sender, EventArgs e) { if (new test(1) != null) { if (new test(1) == new test(1)) { } } }
How do you correctly implement ==?




Reply With Quote