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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:09:54+00:00 2026-06-13T11:09:54+00:00

I want to have an interface specify that any implementations of that interface must

  • 0

I want to have an interface specify that any implementations of that interface must use a subtype of a specific interface in their method declaration:

interface IModel {} // The original type

interface IMapper {
    void Create(IModel model); // The interface method
}

So now I want my implementation of this interface to expect not IModel itself, but a subtype of IModel:

public class Customer : IModel {} // My subtype

public class CustomerMapper : IMapper {
    public void Create(Customer customer) {} // Implementation using the subtype
}

At the moment I’m getting the following error:

‘CustomerMapper’ does not implement interface member ‘IMapper.Create(IModel)’

Is there a way I can achieve this?

  • 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-06-13T11:09:55+00:00Added an answer on June 13, 2026 at 11:09 am

    You need to make your interface generic in the type of value it should expect:

    interface IMapper<T> where T : IModel
    {
        void Create(T model);
    }
    
    ...
    
    public class CustomerMapper : IMapper<Customer>
    {
        public void Create(Customer model) {}
    }
    

    If you don’t make it generic, anything which only knows about the interface couldn’t know what kind of model would be valid.

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

Sidebar

Related Questions

I have a method on an interface that looks like this and I want
How can I specify that I want any object that implements the A interface
I have an interface that I want to implement in separate classes after doing
I want to have a generic object that implements an interface. I mean if
I have a set of objects that I want to conform to an interface,
I have an object that implements an interface. I want to call on the
I have an interface that I want Hibernate to log everything to. My curernt
i'm experimenting with django and the builtin admin interface. I basically want to have
I have a nice interface, and I want to implement one member of it
I have some code using libxml2's SAX2 interface. I want to be able to

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.