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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:27:51+00:00 2026-05-11T05:27:51+00:00

I ended up with something like the following code in a project I’m working

  • 0

I ended up with something like the following code in a project I’m working on. I thought it was really odd that I was allowed to do it, but now I’m starting wonder what is most likely an architectural gaff on my part led me to this.

My questions to you are:

  • What exactly is this called?
  • What are some real world uses of this?
  • Why would anyone want to do this?

Here are my Interfaces:

namespace ThisAndThat {     public interface ICanDoThis     {         string Do();     }      public interface ICanDoThat     {         string Do();     }      public interface ICanDoThisAndThat : ICanDoThis, ICanDoThat     {         new string Do();     } } 

Here’s my concrete class:

namespace ThisAndThat {     public class CanDoThisAndThat : ICanDoThisAndThat     {         public string Do()         {             return 'I Can Do This And That!';         }          string ICanDoThis.Do()         {             return 'I Can Do This!';         }          string ICanDoThat.Do()         {             return 'I Can Do That!';         }     } } 

And my passing tests:

using Xunit;  namespace ThisAndThat.Tests {     public class ThisAndThatTests     {         [Fact]         public void I_Can_Do_This_And_That()         {             ICanDoThisAndThat sut = new CanDoThisAndThat();              Assert.Equal('I Can Do This And That!', sut.Do());         }          [Fact]         public void I_Can_Do_This()         {             ICanDoThis sut = new CanDoThisAndThat();              Assert.Equal('I Can Do This!', sut.Do());         }          [Fact]         public void I_Can_Do_That()         {             ICanDoThat sut = new CanDoThisAndThat();              Assert.Equal('I Can Do That!', sut.Do());         }      } } 
  • 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. 2026-05-11T05:27:51+00:00Added an answer on May 11, 2026 at 5:27 am

    There is absolutely nothing wrong with this code (provided it isn’t confusing for your users), and it isn’t a pattern with any name that I’m familiar with. CanDoThisAndThat implements two interfaces, so clients can use it in either way.

    .NET allows interfaces to be implemented this way — known as explicit interface implementation.

    Explicit interface implementation is useful when:

    1. Two interfaces have the same member definition
    2. You need to implement an interface but don’t want to publicise that a particular member is available to client code that has not declared a reference using the interface type

    An example of case 2 from the .NET framework is ICollection.SyncLock. List<T> implements ICollection yet the following code will not compile because the member has intentionally been ‘hidden’ as the designers of the BCL no longer advocate locking collections in this way:

    List<object> list = new List<object>();  lock (list.SyncRoot) // compiler fails here {     // ... } 

    Any legacy code of this format will still work, because the reference is of type ICollection explicitly:

    ICollection list = new List<object>();  lock (list.SyncRoot) // no problem {     // ... } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a difficult and open-ended question I know, but I thought I'd throw
I just finished writing a function that has ended up with nested code blocks
I ended up writing a quick little script for this in Python, but I
I ended up doing some emergency PM stuff at work and I would like
I'm implementing a interpreter-like project for which I need a strange little scheduling queue.
For local testing the url is something like: http://localhost:29234/default.aspx For staging, the app is
Here's an open ended question. I work on a lot of mssql files, and
In my last job we ended up rewriting the complete ASP.NET stack (forms, controls,
After some find and replace refactoring I ended up with this gem: const class
The same way DOS morphed into Windows? We seem to have ended up supporting

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.