c# - Check if 2 Types are the Same -
I have an object of an unknown type. I am trying to see if it is a special type. I have tried:
obj.GetType () == type (object) and
obj. GetType () .tostring (). Equals (typef (oz). Ostring ()) But none of them works.
How can I see what this is is an object of a particular type? I need to know that this is the exact type, not superclass / subclass of that type.
In the Windows Phone 8.1, I am trying to see from which class the sender was sent.
You were very close.
If you want to see that an object is of type of widget type, you will check in this way:
if (thisObj.GetType () == type (widget )) Objects should be ok are checking for. If you are searching for any lineage subtype, you can use syntax easily: if (this is the oz widget) (When you are trying to find out who is the event sender, the second creation is probably more useful)
Comments
Post a Comment