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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:17:08+00:00 2026-06-06T17:17:08+00:00

I have an interface that has a generic method with two type parameters. I

  • 0

I have an interface that has a generic method with two type parameters. I want to partially explicitly implement that generic method in a class. Is this possible? Some example code below:

public interface ISomeInterface
{
    TResultType Results<TResultsType,TSearchCriteriaType>(TSearchCriteriaType searchCriteria);
}

public class SomeConcrete : ISomeInterface
{
    public TResultsType Results<TResultsType, ConcreteSearchCriteria>(ConcreteSearchCriteria searchCriteria)
{
    return (TResultsType)Results;
}
}

Do I have to explicitly implement both type parameters to make this work?

  • 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-06T17:17:10+00:00Added an answer on June 6, 2026 at 5:17 pm

    Do I have to explicitly implement both type parameters to make this work?

    In order to implement this interface, your class must allow ANY types to be used for that method. (Any types which fit the constraints defined in the interface, which, in this case, since there are no constraints, means any type.)

    You can’t restrict the interface within a specific class implementing it, since this is a generic method (not a generic type), and there is no constraints which cause this to work properly.

    In order to do what you wish, I think, you’d need to make the interface generic:

    public interface ISomeInterface<TSearchCriteriaType>
    {
        TResultType Results<TResultsType>(TSearchCriteriaType searchCriteria);
    }
    

    You can then implement it as:

    public class SomeConcrete : ISomeInterface<ConcreteSearchCriteria>
    { 
        public TResultsType Results<TResultsType>(ConcreteSearchCriteria searchCriteria)
        {
             var results = GenerateResults();
             return (TResultsType)results;
        }
    }
    

    By making the interface generic on the search criteria, you allow your class to implement it based on a specific type for the search criteria.

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

Sidebar

Related Questions

I have a generic class that has one type parameter (T). I needed to
I have an interface IAction that has one generic method: public interface IAction {
I have an interface that has two toolbars, one attached to the frame and
I have an interface (called Subject ) that has the following method: public void
In my business model I have Entity class (IPoint interface ) that has a
I have an interface that contains a single method called ListAll() using System.Collections.Generic; namespace
I have an interface that I want to implement in separate classes after doing
The List<T> class implements the IEnumerable<T> interface. It has a method GetEnumerator that returns
I have an interface that has large numbers of controls, see image below. Interface
I have an existing interface that has a JPanel for displaying pdf files. It

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.