Checking if two Generic object are the same

Hello,

I have a generic class with type U, how can I check if two object are the same.

    public abstract class AStarFindPath<T,U> : MonoBehaviour 
        where U : IAStarPathFinding<U>
    {
            // both are of type U
            U startNode = GetNodeFromWorldPoint (startPos);
            U targetNode = GetNodeFromWorldPoint (targetPos)
            //error CS0019: Operator `==' cannot be applied to operands of type `U' and `U'
            if ( currentNode == targetNode ) {
                        //sw.Stop();
                        //print ("Path found: " + sw.ElapsedMilliseconds + " ms");
                        _pathSuccess = true;
                        break;
                    }

    }

All C# objects have the Equals() method. This is what you can use to test if two objects are equals.

However, what does it mean for two objects to be equal? That is a question with no easy answer. By default, the Equals() method will return true if two reference type objects share the same reference, or if two value type objects have identical field values. It is up to you to define more complex behavior for your custom classes by overriding the Equals() method in your class definition.

Perfect, thanks for the reply, I think since both are ref type and cant share a mem address the default should work just fine.