Which of these pieces of code is faster?
if (obj is ClassA) {}
if (obj.GetType() == typeof(ClassA)) {}
Edit: I\'m aware that they don\'t d
They don't do the same thing. The first one works if obj is of type ClassA or of some subclass of ClassA. The second one will only match objects of type ClassA. The second one will be faster since it doesn't have to check the class hierarchy.
For those who want to know the reason, but don't want to read the article referenced in is vs typeof.