title: IS operator and where an object is coming from
body: <p>I have the following class written by someone else that I'm trying to understand (I omitted the code that is not necessary for this example):</p>
  
  <pre><code>public abstract class UserControl : System.Web.UI.UserControl
  {
         ...
  
          public virtual bool IsAadmin(TheUser theUser)
          {
              if (Page is Page)
                  return ((Page)Page).IsAadmin(theUser);
  
              return false;
          }
  ...
  </code></pre>
  
  <p><em>Edit: (note: in stackoverflow the first <code>Page</code> in the <code>if</code> statement is highlighted blue but in visual studio it isn't)</em></p>
  
  <p>In the <code>if</code> statement intellisense shows that the first Page is of type <code>System.Web.UI.Page Control.Page</code> and the second <code>Page</code> is from <code>Something.Products.Web.Page</code>. When I debug through the code, it doesn't seem to go into this <code>if</code> statement, so I'm wondering what this code is trying to do? But more importantly where is that first <code>Page</code> in the <code>if</code> statement is coming from (initialized)? I'm using <code>Resharper</code> and it suggest replacing the <code>if</code> statement with</p>
  
  <pre><code>var page = Page as Page;
  if (page != null)
  </code></pre>
  
  <p>This change shows that page is null when debugging through it.</p>