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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:38:59+00:00 2026-05-29T18:38:59+00:00

if I have interfaces: public interface ANewThing { IKey Key { get; } }

  • 0

if I have interfaces:

public interface ANewThing { IKey Key { get; } }

public interface AnOldThing { object Key{ get; } }

public interface ACompositeThing : ANewThing , AnOldThing  { }

and I write this:

ACompositeThing compositeThing = GetCompositeThing();  
Trace.WriteLine(compositeThing.Key);

it doesn’t compile, complaining that the call to Key is ambiguous (it doesn’t make any difference if the type returned by the Key property is the same). I am aware that in the class implementing ACompositeThing I can explicitly implement the interfaces ANewThing and AnOldThing, but this doesn’t help me when I have methods which don’t know about the concrete implementations and only know that they will be given ACompositeThing.

So my question is:

Can I do anything in the ACompositeThing interface to say how the Key property ambiguity should be resolved?

Like say ‘when accessing the Key property through this interface, always return the Key property from the ANewThing implementation’?

Or do I have to accept that I can’t do this and must always cast my ACompositeThing to one of the other interfaces before I do the access?

  • 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-29T18:39:01+00:00Added an answer on May 29, 2026 at 6:39 pm

    It’s nasty, but you can declare another member in ACompositeThing:

    public interface ACompositeThing : ANewThing , AnOldThing {
        new IKey Key { get; }
    }
    

    Now that will take preference from the caller’s point of view. However, it means there are now potentially three different implementations – and any ACompositeThing implementation which uses explicit interface implementation for ANewThing.Key will either have to change to expose the member publicly, or add a new member to implement ACompositeThing.Key.

    Of course if you possibly can, you should avoid this – or only use it in a transition from an old interface to a new interface for a very limited time.

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

Sidebar

Related Questions

I have the following Interfaces: public interface ITemplateItem { int Id { get; set;
I have this interface: public interface IValidationCRUD { public ICRUDValidation IsValid(object obj); private void
Currently i have some interfaces (stripped down for here): public interface IJobGroup { string
I have 2 interfaces IA and IB. public interface IA { IB InterfaceB {
I have a bunch of generic interfaces and classes public interface IElement { //
Suppose I have this interface public interface IFoo { ///<summary> /// Foo method ///</summary>
So lets say I have this interface: public interface IBox { public void setSize(int
I have crated an interface like this public interface NetworkInterface { public void onReceive();
I have an interface: public interface IMyInterface { } I have a class which
To keep things simplified lets say I have an interface RandomProvider interface public interface

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.