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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:36:05+00:00 2026-05-26T10:36:05+00:00

If we have the following sample application: interface ITest { string Test { get;

  • 0

If we have the following sample application:

interface ITest
{
    string Test { get; }
}

class A : ITest
{
    string ITest.Test { get { return "Test from A!"; } }
}

class B : A, ITest
{
    string ITest.Test { get { return "Test from B!"; } }
}

Given an instance of B, is it possible to access A’s implementation of ITest?
For example:

B b = new B();
ITest test = b;
string value = test.Test; // "Test from B!"
A a = b;
test = a;
value = test.Test; // Still "Test from B!"

Note, this is no real world problem but more of a general wondering.

  • 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-26T10:36:05+00:00Added an answer on May 26, 2026 at 10:36 am

    No, it’s not. At least not normally – it’s possible that you could do it with reflection.

    Basically, by reimplementing ITest, B is saying that it’s taking complete responsibility for the implementation of ITest.Test within any object of type B – and you can’t even call it from within B which you’d normally be able to if you were overriding in the usual way.

    EDIT: I’ve just proved (in a hacky way) that you can call it with reflection:

    using System;
    
    public interface IFoo
    {
        void Foo();
    }
    
    public class Base : IFoo
    {
        void IFoo.Foo()
        {
            Console.WriteLine("Base");
        }
    }
    
    public class Derived : Base, IFoo
    {
        void IFoo.Foo()
        {
            Console.WriteLine("Derived");
        }
    }
    
    class Test
    {
        static void Main()
        {
            var map = typeof(Base).GetInterfaceMap(typeof(IFoo));            
            var method = map.TargetMethods[0]; // There's only one method :)
            method.Invoke(foo, null);
        }
    }
    

    This prints out “Base”. It’s pretty horrible though – I’d have to be desperate to do it…

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

Sidebar

Related Questions

I have the following test sample: <Window x:Class=WpfScrollTest.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=Window1 Height=200 Width=200> <Border>
I have the following sample code in a VB.NET console application. It compiles and
I have the following piece of snippet Class Sample { Obj_Class1 o1; Obj_Class2 o2;};
I have a simple console application where I have the following setup: public interface
I have a Spring MVC sample application it uses UserDaoImpl class to save a
I have a simple application with the following code: FileInfo[] files = (new DirectoryInfo(initialDirectory)).GetFiles();
I have the following sample XML structure: <SavingAccounts> <SavingAccount> <ServiceOnline>yes</ServiceOnline> <ServiceViaPhone>no</ServiceViaPhone> </SavingAccount> <SavingAccount> <ServiceOnline>no</ServiceOnline>
I have the following sample code which doesn't seem to want to run. import
I have the following sample data: Id Name Quantity 1 Red 1 2 Red
I have the following code sample that im trying to wrap my head around

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.