T
Tony
I have an operator== overload that compares two items and returns a new
class as the result of the comparison (instead of the normal bool)
I then get an ambiguous operater compile error when I attempt to check to
see if the object is null:
"The call is ambiguous between the following methods or properties:
'TestObject.operator ==(TestObject, string)' and 'TestObject.operator
==(TestObject, TestObject)"
Does anyone have any idea how to correct this problem?
Example source follows:
Thanks,
Tony
internal class Condition
{
}
internal class TestObject
{
public static Condition operator==(TestObject oTestObject, string
sValue)
{
return new Condition(); // a stub for illistration purposes
}
public static Condition operator!=(TestObject oTestObject, string
sValue)
{
return new Condition(); // a stub for illistration purposes
}
public static Condition operator==(TestObject oTestObject1, TestObject
oTestObject2)
{
return new Condition(); // a stub for illistration purposes
}
public static Condition operator!=(TestObject oTestObject1, TestObject
oTestObject2)
{
return new Condition(); // a stub for illistration purposes
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override bool Equals(object aObject)
{
return base.Equals(aObject);
}
}
internal class Test
{
void Testmethod()
{
TestObject oTestObject = null;
if (oTestObject == null) // compile error occurs on this line
oTestObject = new TestObject();
}
}
class as the result of the comparison (instead of the normal bool)
I then get an ambiguous operater compile error when I attempt to check to
see if the object is null:
"The call is ambiguous between the following methods or properties:
'TestObject.operator ==(TestObject, string)' and 'TestObject.operator
==(TestObject, TestObject)"
Does anyone have any idea how to correct this problem?
Example source follows:
Thanks,
Tony
internal class Condition
{
}
internal class TestObject
{
public static Condition operator==(TestObject oTestObject, string
sValue)
{
return new Condition(); // a stub for illistration purposes
}
public static Condition operator!=(TestObject oTestObject, string
sValue)
{
return new Condition(); // a stub for illistration purposes
}
public static Condition operator==(TestObject oTestObject1, TestObject
oTestObject2)
{
return new Condition(); // a stub for illistration purposes
}
public static Condition operator!=(TestObject oTestObject1, TestObject
oTestObject2)
{
return new Condition(); // a stub for illistration purposes
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override bool Equals(object aObject)
{
return base.Equals(aObject);
}
}
internal class Test
{
void Testmethod()
{
TestObject oTestObject = null;
if (oTestObject == null) // compile error occurs on this line
oTestObject = new TestObject();
}
}