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 7522607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:34:16+00:00 2026-05-30T02:34:16+00:00

I have a property in a base class that I don’t want overridden for

  • 0

I have a property in a base class that I don’t want overridden for any reason. It assigns an ID to the class for use with a ThreadQueue I created. I see no reason whatsoever for anyone to override it. I was wondering how I can block anyone from attempting to override it short of them changing its modifier.

private int _threadHostID = 0;
    public int ThreadHostID
    {
        get
        {
            if (_threadHostID == 0)
            {
                _threadHostID = ThreadQueue.RequestHostID();
            }
            return _threadHostID;
        }
    }

Edit: totally forgot the language: C#.

Edit2: It is not virtual or overriding anything else so please no sealed.

  • 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-05-30T02:34:18+00:00Added an answer on May 30, 2026 at 2:34 am

    There is no way to stop member hiding. If you don’t make it virtual or abstract, then a derived class cannot override it properly anyway, hiding isn’t polymorphic.

    If a derived class hides it using the new operator, then they are opening up problems for themselves as any code that decides to use a reference to the base class will not touch the derived member. So basically, all code that utilises the “base class”-ness of the type hierarchy will bypass all member hiding anyway.

    The sealed keyword only works if a derived type overrides a base type and doesn’t want it to be overridden further… not sure how it plays with the new operator though. Most likely the member hiding will still be allowed, but will still have the same direct-type problem.

    Your task is done by not making the method virtual or abstract, if a person wants to hide members then they are responsible for anything that breaks because they decided to abuse the design.

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

Sidebar

Related Questions

I have created a BasePage class that inherits from System.Web.Ui.Page. In that base class
I have a base class with a property called Name, which has an XmlText
I have a property within a class, that I need to iterate through all
I have a property on a class that happens to be a Table<T> .
Let's say I have a product class that has a Category property on it.
I have a custom class.And I want if any other class instantiate it then
Here's the situation. I have a base class which implements a method that accepts
I have a base class that I inherit from that has two zero to
How to implement casting to a private base class in C++? I don't want
I have the following classes in my ActiveRecord model: def Property < ActiveRecord::Base #

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.