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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:59:57+00:00 2026-05-22T02:59:57+00:00

I have a situation, where two classes (one deriving from the other) both implement

  • 0

I have a situation, where two classes (one deriving from the other) both implement the same interface explicitly:

interface I
{
  int M();
}

class A : I
{
  int I.M() { return 1; }
}

class B : A, I
{
  int I.M() { return 2; }
}

From the derived class’ implementation of I.M(), I’d like to call the implementation of the base class, but I don’t see how to do it. What I tried so far is this (in class B):

int I.M() { return (base as I).M() + 2; }
// this gives a compile-time error
//error CS0175: Use of keyword 'base' is not valid in this context

int I.M() { return ((this as A) as I).M() + 2; }
// this results in an endless loop, since it calls B's implementation

Is there a way to do this, without having to implement another (non interface-explicit) helper method?


Update:

I know it’s possible with a “helper” method which can be called by the derived class, e.g:

class A : I
{
    int I.M() { return M2(); }
    protected int M2 { return 1; }
}

I can also change it to implement the interface non-explicitly. But I was just wondering if it’s possible without any of these workarounds.

  • 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-22T02:59:58+00:00Added an answer on May 22, 2026 at 2:59 am

    Unfortunately, it isn’t possible.
    Not even with a helper method. The helper method has the same problems as your second attempt: this is of type B, even in the base class and will call the implementation of M in B:

    interface I
    {
      int M();
    }
    class A : I
    {
      int I.M() { return 1; }
      protected int CallM() { return (this as I).M(); }
    }
    class B : A, I
    {
      int I.M() { return CallM(); }
    }
    

    The only workaround would be a helper method in A that is used in A‘s implementation of M:

    interface I
    {
      int M();
    }
    class A : I
    {
      int I.M() { return CallM(); }
      protected int CallM() { return 1; }
    }
    class B : A, I
    {
      int I.M() { return CallM(); }
    }
    

    But you would need to provide a method like this also for B if there will be a class C : B, I…

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

Sidebar

Related Questions

I have this weird situation. I have these two classes: Public Class Entry End
First I want to describe my situation briefly. I have two classes, one MainClass
This is the situation: I have two tables where the one references the other
Imagine a situation, I have PC with two lan cards, one is connected to
I have two classes. One(Person) for getters and setters, and another(People) for compute the
I have this situation (two classes with two different header files): b.h #include a.h
I have two classes: Parent and Child , mapped one-to-many with relationship owned by
I have a situation where I have two arrays and I use one array(A)
I have a situation like, I have two tables having same structure. I have
My situation is that I have two Classes : Person and Group. In every

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.