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

Ask A Question

Stats

  • Questions 231k
  • Answers 231k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Should one blindly trust the DTA advise and implement all… May 13, 2026 at 2:09 am
  • Editorial Team
    Editorial Team added an answer Have you looked into System.Drawing.SystemFonts? I think it may have… May 13, 2026 at 2:09 am
  • Editorial Team
    Editorial Team added an answer This question was posed using the word "layer," so my… May 13, 2026 at 2:09 am

Related Questions

I ended up with something like the following code in a project I'm working
I was wondering whether using a Belt and Braces (Suspenders) approach to programming -
[Sorry for long question but it is necessary to explain the problem] I am
I just finished writing a function that has ended up with nested code blocks
For local testing the url is something like: http://localhost:29234/default.aspx For staging, the app is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.