title: What's the point in using "is" followed by "as" instead of "as" followed by a null check in C#?
body: <p>While reading C# code I found a rather curious snippet:</p>
  
  <pre><code>if( whatever is IDisposable) {
    (whatever as IDisposable).Dispose();
  }
  </code></pre>
  
  <p>I'd rather expect that being done either like this:</p>
  
  <pre><code>if( whatever is IDisposable) { //check
    ((IDisposable)whatever).Dispose(); //cast - won't fail
  }
  </code></pre>
  
  <p>or like this:</p>
  
  <pre><code>IDisposable whateverDisposable = whatever as IDisposable;
  if( whateverDisposable != null ) {
     whateverDisposable.Dispose();
  }
  </code></pre>
  
  <p>I mean <code>as</code> is like a cast, but returns <code>null</code> on failure. In the second snippet it can't fail (since there's a <code>is</code> check before).</p>
  
  <p>What's the point in writing code like in the first snippet instead of like in the second or in the third?</p>