外I次のシナリオがあります。C#のオーバーロード演算子==クラス
public class SomeClass {
// Have some other data members as well
public int i ;
}
public class TestClass {
public bool SomeFunction() {
SomeClass a = new SomeClass();
SomeClass b = new SomeClass();
if (a == b) // this is where I am getting compile error
return true;
return false;
}
public static bool operator==(SomeClass a, SomeClass b) {
if (a.i == b.i)
return true;
// compare some other members as well
return false;
}
}
は、C#で達成することが、このことは可能ですか?
ありがとうございました!
なぜあなたはクラスを外したいですか? –
実際のコードでは、クラス "SomeClass"の上の例では、他の誰かであり、私はそれを検証しようとしています – test123