"StringComparison.CurrentCulture" How to tell the outcome?

Hello everyone,

I’m messing around with comparing “strings” from different “grid cells”. I have the grind cells marked by numbers and am messing with comparing the cell number “objects” by name and stumbled upon a “string.Compare” method and was wondering where the outcome of the compared method is placed?

So say it went something like this,

        public object objects;

        public int CompareTo()
        {
            if (objects == null) return 1;

            Block checkRightSpace = objects as Block;
            if (checkRightSpace != null)
                return string.Compare(this.name, checkRightSpace.name, StringComparison.CurrentCulture);
            else
                throw new ArgumentException("Object is not a MatchPieceType");
        }

How do I tell if they matched? Something like a debug to see if they did match.

Hey there,
string.Compare will return zero when the strings are equal in the sort order. You can check the return value for this case and print out whatever you like. I would caution you, however, that comparing many strings can have a substantial impact on your games performance if you are comparing thousands of them each frame. Stick to integers if you need to make many comparisons.