What is the best way to determine if two objects are of the same type? The
'is' operator is not precise enough. Currently I am using
Obj1.GetType().Name == Obj2.GetType().Name but it seems to me there must be
a better way. The following code gives a better idea of the situation:
abstract class A
{
//the arguments could be instances of any of the classes defined
static void TestFunc(A obj1, A obj2)
{
if(obj1.GetType().Name == obj2.GetType().Name)
{ ... //some code}
else
{ ... // do something else }
}
}
class B {} : A
class B2 {} : A
class C {} : B
Just a thought: would (Obj1 is Obj2 && Obj2 is Obj1) work better and be more
efficient?
--Ken