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

  • Home
  • SEARCH
  • 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 846039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:33:01+00:00 2026-05-15T06:33:01+00:00

Sorry about the strange title. I really have no idea how to express it

  • 0

Sorry about the strange title. I really have no idea how to express it any better…

I get an error on the following snippet. I use the class Dummy everywhere. Doesn’t the compiler understand the constraint I’ve added on DummyImplBase? Is this a compiler bug as it works if I use Dummy directly instead of setting it as a constraint?

Error 1 ‘ConsoleApplication53.DummyImplBase’ does not implement interface member ‘ConsoleApplication53.IRequired.RequiredMethod()’. ‘ConsoleApplication53.RequiredBase.RequiredMethod()’ cannot implement ‘ConsoleApplication53.IRequired.RequiredMethod()’ because it does not have the matching return type of ‘ConsoleApplication53.Dummy’. C:\Documents and Settings\simen\My Documents\Visual Studio 2008\Projects\ConsoleApplication53\ConsoleApplication53\Program.cs 37 27 ConsoleApplication53

public class Dummy
{
}

public interface IRequired<T>
{
    T RequiredMethod();
}

public interface IDummyRequired : IRequired<Dummy>
{
    void OtherMethod();
}

public class RequiredBase<T> : IRequired<T>
{
    public T RequiredMethod()
    {
        return default(T);
    }
}

public abstract class DummyImplBase<T> : RequiredBase<T>, IDummyRequired
    where T: Dummy
{
    public void OtherMethod()
    {
    }
}
  • 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-15T06:33:02+00:00Added an answer on May 15, 2026 at 6:33 am

    You could add this to DummyImplBase:

       public Dummy RequiredMethod() { return base.RequiredMethod(); }
    

    EDIT: Or, if you’re using C# 4.0, you could change definition of IRequired like so:

    public interface IRequired<out T>
    

    then remove IDummyRequired and you would still be able to assign derived classes to
    IRequired<Dummy> (but not to IDummyRequired).

    2nd EDIT: Your original code did not compile, because T could be Dummy or a class derived from Dummy. And the implemented Method

    public DummyDerived RequiredMethod() 
    

    has not the same as signature as

    public Dummy RequiredMethod()
    

    which was declared in IDummyDerived.

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

Sidebar

Related Questions

(Sorry for strange title, haven't come up with anything better..) Background I use nunit-console
Sorry the title isn't more help. I have a database of media-file URLs that
Sorry if the title is poorly descriptive, but I can't do better right now
First of all, sorry about the title -- I couldn't figure out one that
I'm getting a really strange error when making a method call: /* input.cpp */
Edit: When I say SQL Server, I'm really talking about the Management Studio. Sorry
Sorry about the title. I do realize it's not very descriptive. :| Here is
(ps: sorry about my english) I have a text field in my application and
Well, sorry about the confusing title but I'm having a slightly annoying problem with
at first, sorry about my english. My question is: I have php generated dynamic

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.