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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:21:06+00:00 2026-05-15T21:21:06+00:00

Sorry for asking what seems like such an obvious question. I have an adapter

  • 0

Sorry for asking what seems like such an obvious question.

I have an “adapter” generic class of type T where T is a defined interface. I want to create a method in that class which takes a different type of generic adapter.

public interface ICommon { }
public class TypeOne : ICommon { }
public class TypeTwo : ICommon { }

public class Adapter<T> where T : ICommon
{
    void TakeAnotherType(Adapter<S> other)
    { }
}

This gives me a compilation error Cannot resolve symbol 'S'.

I would like to be able to do;

    MyOne one = new Adapter<TypeOne>();
    MyTwo two = new Adapter<TypeTwo>();
    one.TakeAnotherType(two);

If I change the method to take Adapter<T> then it complains that “two” isn’t of type Adapter<TypeOne>

  • 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-15T21:21:07+00:00Added an answer on May 15, 2026 at 9:21 pm
    void TakeAnotherType<S>(Adapter<S> other) where S:ICommon
    { }
    

    Because the generic type T of Adapter is constrained to ICommon, it is important to also constrain S in the same way, as this is used as the generic type for Adapter<T>, so it must also satisfy the ICommon constraint.

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

Sidebar

Related Questions

Sorry for asking silly question.. I have an array with class objects like: Class
First off, I'm sorry for asking such a simple question in such a sophisticated
Sorry for asking such a question again. I've been looking for a solution for
I am sorry if I am asking the question poorly. I have a Rails
Sorry for asking a stupid question but I have a problem that makes me
Sorry for asking a rather n00b question, I am rather new to ASP.NET MVC.
sorry for asking this dumb question i will try to explain as good as
I am new to Cstring, sorry for asking dumb question, please help. char string[10];
Sorry I'm asking too many questions in a row. I have a list of
yes its a joomla question and im sorry to annoy but asking on the

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.