Question:
How to check the type of an object at runtime in C#?
Answer:
Only is
will return true
if obj
is a subclass of MyObject
, sometimes this is not desirable. For exact comparison of types, write like this:
obj.GetType() == typeof(MyObject)