I tried to debug the problem and ran into this problem. Maybe someone can explain this to me. This is the code in question
public int Compare(CustomClass rt1, CustomClass rt2)
{
if (rt1 == null & rt2 == null)
return 0;
if (rt1 == null)
return -1;
if (rt2 == null)
return 1;
if (rt1.yPos < rt2.yPos)
return -1;
if (rt1.yPos == rt2.yPos)
{
if (rt1.xPos < rt2.xPos)
return -1;
if (rt1.xPos == rt2.xPos)
return 0;
}
return 1;
}
The error I was getting was: IComparer (or the IComparable methods it relies on) did not return zero when Array.Sort called x. Sotrage Too (x).
To make it even more interesting, an error will not occur if I run it from VS in debug mode. Only if I put it in release mode AND click "start without debugging". Anyone have any idea why this will happen? I fixed the problem by adding "if (rt1 == rt2) return 0;" lines to the beginning of the function, but I would like to know what is happening.
Additional Information: Yes, this implements the IComparer class