» Back to Documentation

In C++ there is an easy way to determine if two pointers represent the same object- just compare them using the equality operator!

In C# we compare references, however, this poses a problem because two distinct .NET wrappers can be created for the same C++ pointer/object. Therefore comparing the references will give you incorrect results unless you are sure they were created as the same wrapper.

Max.NET makes all objects derived from IInterfaceServer (which is the base class for most pluggable 3dsmax classes) implement the IComparable operator.

Therefore, to see if object1 and object2 are the same 3dsmax object you need to write the following:

bool sameObject = object1.Equals( object2 as IInterfaceServer );