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

  • Home
  • SEARCH
  • 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 8218327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:45:23+00:00 2026-06-07T12:45:23+00:00

I know that the access specifier visibility of the overridden method/property must be the

  • 0

I know that the access specifier visibility of the overridden method/property must be the same or above as that of the base method/property and I also know that the visibility of members of interfaces is public by default. So how and why can the visibility of the members be private when we implement the interface explicitly in a class though those private methods can be accessed by casting the class object to the implemented interface?

    public interface IRocker
{
    string RockOff(string str);
}
public abstract class AmAbstract
{
    public abstract string SomeMethod(string str);
}
class Program : AmAbstract, IRocker
{
    static void Main(string[] args)
    {
        new Hello().RockU();
        Console.ReadKey();
    }

    string IRocker.RockOff(string str)
    {
        return str;
    }

    public override string SomeMethod(string str)
    {
        return str;
    }
}

public class Hello
{
    public void RockU()
    {
        Console.WriteLine(((IRocker)(new Program())).RockOff("Damn"));
        Console.WriteLine(((AmAbstract)(new Program())).SomeMethod("lalalalala"));

    }
}

‘Console.WriteLine(((IRocker)(new Program())).RockOff(“Damn”));’ statement shows us ultimately accessing a private method of the class ‘Program’. My question is why we can’t hide the visibility of an abstract method as we can with an interface method? And why we are able to access private method through interface? Any help will be highly appreciated.

  • 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-07T12:45:25+00:00Added an answer on June 7, 2026 at 12:45 pm

    You are using explicit interface implementation when implementing IRocker.RockOff(). There are separate rules for those in C#, and in fact these are kind of private and public at the same time.

    A quote from paragraph 13.4.1 of the C# 4.0 specification:

    Explicit interface member implementations have different accessibility characteristics than other members. Because explicit interface member implementations are never accessible through their fully qualified name in a method invocation or a property access, they are in a sense private. However, since they can be accessed through an interface instance, they are in a sense also public.

    Explicit interface member implementations serve two primary purposes:

    • Because explicit interface member implementations are not accessible through class or struct instances, they allow interface implementations to be excluded from the public interface of a class or struct. This is particularly useful when a class or struct implements an internal interface that is of no interest to a consumer of that class or struct.
    • Explicit interface member implementations allow disambiguation of interface members with the same signature. Without explicit interface member implementations it would be impossible for a class or struct to have different implementations of interface members with the same signature and return type, as would it be impossible for a class or struct to have any implementation at all of interface members with the same signature but with different return types.

    There are no such exceptions for abstract classes, so just the regular modifier rules apply.

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

Sidebar

Related Questions

I want to know that how to add variables (i.e. with which access specifier)
We know that if we try to access a nonexistent key of std::map with
I know that using friends_work_history permission, we can access friend's work history. Now, I
I know that's bad design, but I need access to the view from my
Does anybody know if you can access the SaevFileDialog control that's used by the
I just want to know how to access an array in SMARTY that have
Can anyone let me know how can access an element of a list that
I dont know how to acces my method of my class ProjectNode, that is
I know that there isn't way to access to the links of variables in
I know that there're few differences between struct and class in C++. I also

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.