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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:31:47+00:00 2026-05-27T01:31:47+00:00

The C# language specification says that if I inherit a class, and the base

  • 0

The C# language specification says that if I inherit a class, and the base class and derived class have the same named member with the same signature, then I have to use the new keyword to hide the base class member (There is another way by using virtual and override keyword in base and derived class member).

But in practice I found that the derived class auto hides the derived member if it has the same named member. So what is the main benefit and problem new keyword in same named derived class member?

  • 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-27T01:31:48+00:00Added an answer on May 27, 2026 at 1:31 am

    New is not required, as you note. It is optional, and if you do not use it, you get a warning. You are entirely correct to note that this is at first glance a strange design decision.

    The purpose of this design decision is to help mitigate a class of problems known as the “Brittle Base Class” problems. Here’s a version of that problem:

    Foo Corporation creates a class Frobber and ships it in Foo.DLL version 1.0:

    namespace FooCorp
    {
      public class Frobber
      {
        public void Frobnicate() { ... }
        ...
    

    Bar Corporation, who you work for, makes Blobbers. A Blobber can do everything that a Frobber can do, but in addition, it can Blobnicate too. So you decide to re-use the implementation of Frobnicate from FooCorp, and add some additional functionality:

    namespace BarCorp
    {
      public class Blobber : FooCorp.Frobber
      {
        public void Blobnicate() { ... }
        ...
    

    Foo Corporation realizes that people like to Blobnicate, and they decide to ship Foo.DLL v2.0:

    namespace FooCorp
    {
      public class Frobber
      {
        public void Frobnicate() { ... }
        public void Blobnicate() { ... }
        ...
    

    When you get a new version of Foo.DLL and recompile, you want to be told that you are now accidentally introducing a new method that shadows a base class method. That is possibly a dangerous thing to do; your class was written with the assumption that the base class was a Frobnicator, but apparently now it is a Blobnicator too! That fact could break your customers, who might accidentally call the base class version when they intended to call your derived class version.

    We make “new” optional so that it is legal for you to shadow a base class method without changing your source code. If we made it illegal then FooCorp would have broken your build with their upgrade. But we make it a warning so that you know that you might be doing so accidentally. You can then examine the code carefully; if you decide that your implementation of Blobnicate is now redundant, you can remove it. If it is still good, you can mark it as “new” and eliminate the warning.

    Make sense? This is one of the subtle features of C# that make it suitable for large scale multi-version component-oriented software.

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

Sidebar

Related Questions

I have read about partial methods in the latest C# language specification , so
Using Flex and Bison, I have a grammar specification for a boolean query language,
The Scala language specification section 6.19 says: A for comprehension for (p <- e)
The Java Virtual Machine Specification says that there is limited support for boolean primitive
According to CSharp Language Specification. An interface defines a contract that can be implemented
I was wondering which edge cases exist that could make Common Language Specification compliance
Is there a language specification for clojure? Something that precisely defines the lexical syntax
According to the Java Language Specification : If there are any enclosing try statements
The C# language specification defines the empty-statement grammar production, which allows me to do
I've got a copy of the Word document C# Language Specification Version 1.2 and

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.