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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:20:07+00:00 2026-05-23T08:20:07+00:00

There is a base class (black box; can’t modify it) that I derive from.

  • 0

There is a base class (black box; can’t modify it) that I derive from. In my derived class, I no longer want to allow users to use a property, instead I have a public function now to use instead. I won’t go into the details of why (it is irrelevant), but here is the property I’m trying to hide:

public ComboBoxItemCollection Items { get; }

I’ve tried this, but it didn’t work:

private new ComboBoxItemCollection Items { get; set; }

I also tried this, however the compiler says I am not allowed to make both accessors private:

public new ComboBoxItemCollection Items { private get; private set; }

How do I properly accomplish this? Note that I’m not depending on this being a complete security solution, obviously through means of casting to the base class they can still call this property. This is simply meant to offer the user a compile-time error, which helps guide them to realize they cannot use this property and instead should use the new function in the derived class.

EDIT

Thanks to the answers in this thread, I came up with the following solution:

    [Obsolete( "This property is obsolete. Please use MRUIdComboBox.AddItem() instead.", true )]
    public new ComboBoxItemCollection Items
    {
        get
        {
            throw new NotSupportedException( "This property is not supported. Please use MRUIdComboBox.AddItem() instead." );
        }
    }
  • 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-23T08:20:08+00:00Added an answer on May 23, 2026 at 8:20 am

    You can’t. The closest you could come would be:

    [Obsolete(IsError=true)]
    public new ComboBoxItemCollection Items
    {
        get { return base.Items; } // Or throw an exception
    }
    

    Personally I’d be tempted to ask whether you should really be deriving from this if you don’t want all the members though… can you use composition instead?

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

Sidebar

Related Questions

Are there any dictionary classes in the .NET base class library which allow duplicate
Let's say I have a Base class and several Derived classes. Is there any
I have a base class that I want to look like this: class B
Given a base class that is inherited by plethora of derived classes, and a
I have a base class Foo that has an Update() function, which I want
Sometimes it's useful to derive my entities from a base class like this: public
Is there anyway to discover the base class of a class in Python? For
Is there a better way of binding a list of base class to a
In VB.NET there is a keyword 'shadows'. Let's say I have a base class
I have these classes: class Base { ... private: std::vector<X> v; }; class Derived

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.