I have an object named Shape that contains a field public int[,] coordinate { get; set; } public int[,] coordinate { get; set; } public int[,] coordinate { get; set; } .
I have a separate class that has a collection of Shape objects. At some point I want to check:
if(shapes.Contains(shape)) {
So, in the Shape class, I added the IComparable link and inserted the CompareTo method:
public int CompareTo(Shape other) { return this.coordinate.Equals(other.coordinate); }
However, I get the error message:
Cannot implicitly convert type 'bool' to 'int'
How do I therefore phrase return to return int rather than bool, since it is doing this at the moment?
UPDATE
If you change the return code to:
return this.coordinate.CompareTo(other.coordinate);
I get the following error message:
Error 1 'ShapeD.Game_Objects.Shape' does not implement the member of the interface 'System.IComparable.CompareTo (ShapeD.Game_Objects.Shape)'. 'ShapeD.Game_Objects.Shape.CompareTo (ShapeD.Game_Objects.Shape)' cannot implement 'System.IComparable.CompareTo (ShapeD.Game_Objects.Shape)' because it does not have the corresponding return type 'int'. C: \ Users \ Usmaan \ Documents \ Visual Studio 2012 \ Projects \ ShapeD \ ShapeD \ ShapeD \ Game Objects \ Shape.cs 10 18 ShapeD
source share