Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8175525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:48:52+00:00 2026-06-06T22:48:52+00:00

I have the following class written by someone else that I’m trying to understand

  • 0

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):

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;
        }
...

Edit: (note: in stackoverflow the first Page in the if statement is highlighted blue but in visual studio it isn’t)

In the if statement intellisense shows that the first Page is of type System.Web.UI.Page Control.Page and the second Page is from Something.Products.Web.Page. When I debug through the code, it doesn’t seem to go into this if statement, so I’m wondering what this code is trying to do? But more importantly where is that first Page in the if statement is coming from (initialized)? I’m using Resharper and it suggest replacing the if statement with

var page = Page as Page;
if (page != null)

This change shows that page is null when debugging through it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:48:53+00:00Added an answer on June 6, 2026 at 10:48 pm

    The “first page” is actually a Page property of UserControl class your abstract UserControl inherits from. It’s of type System.Web.UI.Page and, as per documentation, returns

    a reference to the Page instance that contains the server control.

    The is keyword evaluates to true when

    the provided expression is non-null, and the provided object can be cast to the provided type without causing an exception to be thrown.

    It seems that when you were debugging your code, the examined UserControl was not contained in a page of type Something.Products.Web.Page.

    Regarding the Resharper suggestion: in your original code, you are effectively casting the Page property twice – first, when using is keyword and second when casting it explicitly. With the code generated by Resharper, the cast only occurs once. When the if statement evaluates to true, you can be sure that the page variable holds a reference to the Something.Products.Web.Page and do not have to cast it again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have written the following code class Program { static void Main(string[] args) {
I have a dll written by someone else and that has many flaws. Let's
i have the following class that writes to a file but is not working
I have the following class written for PHP 5.4.x. Should this work as I
I have written the following Utility class to get an instance of any class
I have written a module similar to the following: module One class Two def
I have following code class User attr_accessor :name end u = User.new u.name =
I have written the following code in an effort to try and compute the
I have written the following code, but continually get a 'non-static method getText() can
I've been trying to find what the problem is to this following code part.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.