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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:00:54+00:00 2026-05-13T22:00:54+00:00

I would like make an extension method for the generic class A which takes

  • 0

I would like make an extension method for the generic class A which takes yet another generictype (in this example TC), but i guess that aint possible?

class Program
{
    static void Main(string[] args)
    {
        var a = new A<B, B>();
        a.DoIt<B>();
    }
}

static class Ext
{
    public static A<TA, TB> DoIt<TA, TB, TC>(this A<TA, TB> a)
    {
        return a;
    }
}

class A<TA, TB> { }
class B { }
  • 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-13T22:00:54+00:00Added an answer on May 13, 2026 at 10:00 pm

    If you can accept a slight syntax change, then it would be possible.

    Change it to:

    var a = new A<B, B>(); 
    a.Do().It<B>(); 
    

    The trick is that the Do method is an extension method on A<TA, TB>:

    public static Doer<TA, TB> Do<TA, TB>(this A<TA, TB> a)
    {
        return new Doer<TA, TB>(a);
    }
    

    The trick is that this signature lets type inferincing pick up TA and TB from a so that you don’t have to specify them explicitly.

    The Doer class provides the generic method you need:

    public class Doer<TA, TB>
    {
        public void It<TC>() { }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this sounds like a subjective answer, but I will try to make
I'm building a web application, and I would like to make certain functions on
I've created a PHP class that envelopes filter_input functions to make our developer's life
This is one of the hardest questions I've ever had to title here on
I have a class library that wraps the command line client for Mercurial. My
There's a method in a library out of my control that uses a block
from what dll can i get the extension of Intercept ? I've added Ninject.Extensions.Interception
I am using EF4 CPT4 Code first and I have setup my ObjectContext to
I'm new to asp.net mvc. I just created the default asp.net mvc project in
I am working on a client/server game (C#.NET) where I do not want 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.