<p>It's <a href="http://www.codeproject.com/KB/cs/csharpcasts.aspx" rel="noreferrer">shown</a> that 'as' casting is much faster than prefix casting, but what about 'is' reflection?  How bad is it?  As you can imagine, searching for 'is' on Google isn't terribly effective.</p>

[{'answer_id': 57705, 'author': 'Curt Hagenlocher', 'author_id': 533, 'author_profile': 'https://Stackoverflow.com/users/533', 'pm_score': 3, 'selected': False, 'text': '<p>"is" is basically equivalent to the "isinst" IL operator -- which that article describes as fast.</p>\n'}, {'answer_id': 57707, 'author': 'rpetrich', 'author_id': 4007, 'author_profile': 'https://Stackoverflow.com/users/4007', 'pm_score': 2, 'selected': False, 'text': '<p>It should be quick enough to not matter. If you are checking the type of an object enough for it to make a noticeable impact on performance you need to rethink your design</p>\n'}, {'answer_id': 57713, 'author': 'swilliams', 'author_id': 736, 'author_profile': 'https://Stackoverflow.com/users/736', 'pm_score': 3, 'selected': False, 'text': "<p>The way I learned it is that this:</p>\n\n<pre><code>if (obj is Foo) {\n  Foo f = (Foo)obj;\n  f.doSomething();\n}\n</code></pre>\n\n<p>is slower than this:</p>\n\n<pre><code>Foo f = obj as Foo;\nif (f != null) {\n  f.doSomething();\n}\n</code></pre>\n\n<p>Is it slow enough to matter? Probably not, but it's such a simple thing to pay attention for, that you might as well do it.</p>\n"}, {'answer_id': 57828, 'author': 'Daniel Fortunov', 'author_id': 5975, 'author_profile': 'https://Stackoverflow.com/users/5975', 'pm_score': 5, 'selected': True, 'text': "<p>There are a few options:</p>\n\n<ol>\n<li>The <strong>classic cast</strong>: <code>Foo foo = (Foo)bar</code></li>\n<li>The <strong><code>as</code> cast operator</strong>: <code>Foo foo = bar as Foo</code></li>\n<li>The <strong><code>is</code> test</strong>: <code>bool is = bar is Foo</code></li>\n</ol>\n\n<hr>\n\n<ol>\n<li>The <strong>classic cast</strong> needs to check if <code>bar</code> can be safely cast to <code>Foo</code> (quick), and then actually do it (slower), or throw an exception (really slow).</li>\n<li>The <strong><code>as</code> operator</strong> needs to check if <code>bar</code> can be cast, then do the cast, or if it cannot be safely cast, then it just returns <code>null</code>.</li>\n<li>The <strong><code>is</code> operator</strong> just checks if <code>bar</code> can be cast to Foo, and return a <code>boolean</code>.</li>\n</ol>\n\n<p>The <strong><code>is</code></strong> test is quick, because it only does the first part of a full casting operation. The <strong><code>as</code></strong> operator is quicker than a classic cast because doesn't throw an exception if the cast fails (which makes it good for situations where you legitimately expect that the cast might fail).</p>\n\n<p>If you just need to know if the variable <code>bar</code>is a <code>Foo</code> then use the <strong><code>is</code></strong> operator, <strong>BUT</strong>, if you're going to test if <code>bar</code> is a <code>Foo</code>, and if so, <strong>then cast it</strong>, then you should use the <strong><code>as</code></strong> operator.</p>\n\n<p>Essentially every cast needs to do the equivalent of an <code>is</code> check internally to begin with, in order to ensure that the cast is valid. So if you do an <code>is</code> check followed by a full cast (either an <code>as</code> cast, or with the classic cast operator) you are effectively doing the <code>is</code> check twice, which is a slight extra overhead.</p>\n"}]
['https://Stackoverflow.com/questions/57701', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3279/']