I am getting a System.StackOverFlowException when the code hits this function.
Where stringtype is user defined tupe and equals int the function in the type library.
public static bool Equals(StringType leftHand, StringType rightHand)
{
if (leftHand == rightHand)
{
return true;
}
if ((leftHand == "0") || (rightHand == "0"))
{
return false;
}
return (leftHand.myValue.Equals(rightHand.myValue) && leftHand.myState.Equals(rightHand.myState));
}
This
if (leftHand == rightHand)
change to
if (object.ReferenceEquals(leftHand, rightHand))
You probably redefined the == operator to call Equals.
And I hope you don't have an implicit operator that from string creates StringType, because otherwise
if ((leftHand == "0") || (rightHand == "0"))
will probably call itself for the same reason.
Probably
if ((leftHand.myValue == "0") || (rightHand.myValue == "0"))
would be better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With