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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:00:25+00:00 2026-05-23T06:00:25+00:00

I have the following base interface public interface IBaseAction { bool CanAct(…) } and

  • 0

I have the following base interface

public interface IBaseAction
{
   bool CanAct(...)
}

and two inheriting interface say

public interface IAction1 : IBaseAction{}

and

public interface IAction2 : IBaseAction{}

My problem is, I have a class which implements both, and I want to implement CanAct DIFFERENTLY.

public class ComplexAction : IAction1, IAction2
{
   bool IAction1.CanAct(...){} //doesn't compile as CanAct is not a member of IAction1!!
}

ComplexAction c=new ComplexAction();
var a1 = (IAction1)c;
var a2 = (IAction2)c;
a1.CanSave(); //THESE TWO CALLS SHOULD BE IMPLEMENTED DIFFERENTLY
a2.CanSave();

Is there a reasonably clean way to do this?
(Also, my interfaces have semantic meaning and at least three more functions, so it is out of the question to throw out the whole hierarchy, but I’d be willing to copy bool CanAct to every inheriting interface if that is the only solution (there are 4-6 of them))

  • 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-23T06:00:26+00:00Added an answer on May 23, 2026 at 6:00 am

    And what the CLR is supposed to do if someone calls ((IBaseAction)a1).CanSave()? There could be just one implementation for IBaseAction.CanSave(). So I think you can’t do this conceptually.

    This is a fundamental problem of multiple inheritance called the diamond problem. The bottom line is: if you hit it, your type hierarchy design is definitely wrong.
    E.g. in this particular case, you’re better off with the Role class model (also known as the Role pattern).

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

Sidebar

Related Questions

I have the following interface declared in C#: public interface ArtistInterface { bool Flag
Suppose I have the following (trivially simple) base class: public class Simple { public
Let's say I have the following class hierarchy in C++: class Base; class Derived1
I have created an interface which I am inheriting from another (COM) interface: public
I have defined the following interface: public interface IHaveAProblem { string Issue { get;
I have the following generic question Here is a my generic message interface. public
I have the following base abstract class defined as: public abstract class BaseObject<T> :
I have the following situation: // A public interface of some kind public interface
I have got the following interface definition: public interface ICommandHandler { ILogger Logger {
I'm not sure what's going on. I have the following base class: public class

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.