Although this is not AutoCAD or Autodesk related, I always see developers doing .NET code that can be optimized. Sure in some cases this is not a concern, or the processing time that will be saved doesn’t worth the trouble. But doing some small good practices can save you big at the end of your project.
So this post is quite simple and about type comparison. The idea came from this interesting post: Drilling into .NET Runtime microbenchmarks: 'typeof' optimizations.
Basically it says that the following type comparison is the faster:
Entity ent = // initialize here
if (ent.GetType() == typeof(Line))
As well pointed by the comments (see below), the variations of object type comparison shown here (and the linked post) will produce different results. So you need make sure which is one is the correct for each scenario. Once that is decided, I would suggest review the performance trade off of your choice at the linked post.