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

The Archive Base Latest Questions

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

If you declare an inheritance hierarchy where both the parent and child class have

  • 0

If you declare an inheritance hierarchy where both the parent and child class have a static method of the same name and parameters*, Visual Studio will raise warning CS0108:

Example:

public class BaseClass
{
    public static void DoSomething()
    {
    }
}

public class SubClass : BaseClass
{
    public static void DoSomething()
    {
    }
}

: warning CS0108: 'SubClass.DoSomething()' hides inherited member 'BaseClass.DoSomething()'. Use the new keyword if hiding was intended.

Why is this considered method hiding? Neither method is involved in the inheritance hierarchy and can only be invoked by using the class name:

BaseClass.DoSomething();
SubClass.DoSomething();

or, unqualified in the class itself. In either case, there is no ambiguity as to which method is being called (i.e., no ‘hiding’).

*Interestingly enough, the methods can differ by return type and still generate the same warning. However, if the method parameter types differ, the warning is not generated.

Please note that I am not trying to create an argument for or discuss static inheritance or any other such nonsense.

  • 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-22T15:20:08+00:00Added an answer on May 22, 2026 at 3:20 pm

    Members of the SubClass will not be able to access the DoSomething from BaseClass without explicitly indicating the class name. So it is effectively “hidden” to members of SubClass, but still accessible.

    For example:

    public class SubClass : BaseClass
    {
        public static void DoSomething()
        {
        }
    
        public static void DoSomethingElse()
        {
            DoSomething(); // Calls SubClass
            BaseClass.DoSomething(); // Calls BaseClass
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I declare a base class as follows: abstract class Parent { protected static
I have a class manipulating only shared_ptr to an inheritance hierarchy (quite simple, there
I have a classical virtual inheritance diamond: class A { protected: A(const char *x)
Let's say I have two classes. Both have the same member fields (including the
I have the following two interfaces, which are not part of an inheritance hierarchy.
If I have this kind of hierarchy: #include <iostream> using namespace std; template<class T>
I have a question regarding Spring inheritance: Let's say I have a class (bean)
I have a few classes which are the same level in a subtype hierarchy.
What i'm tring to do is this. I have a Inheritance tree that looks
Suppose I have a base and derived class: class Base { public: virtual void

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.