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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:45:02+00:00 2026-05-16T18:45:02+00:00

I understand this statement :- List<string> a; which means that a can contain values

  • 0

I understand this statement :-

List<string> a;

which means that a can contain values of only string type.

But when used with methods i get confused. For eg.

public T1 methodName <T1,T2>(T1 t, T1 p)

I understand the method is returning object of type T1 and accepts objects of type T1. But what is the significance of <T1,T2>? Why is it required?

Edit :-
Based on the answers i received, i guess <T1, T2> are there so that input arguments looks similar. If <T1> was there then all input arguments must be of type T1 and if <T1,T2> is there means all arguments must be of type either T1 or T2

But what exactly is meant by this statement :-

public static TSummary Accumulate <TInput, TSummary> (IEnumerable <TInput> coll, Action <TInput, TSummary> action)

The definition says all input must be of either TInput or TSummary but the second argument is of type Action. So i am still confused.

Thanks in advance 🙂

  • 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-16T18:45:02+00:00Added an answer on May 16, 2026 at 6:45 pm

    If the method is really defined in the way that you’ve typed exactly:

    public T1 methodName <T1, T2>(T1 t, T1 p)
    

    …then T2 is unrelated to the argument types or return type. It might affect what’s happening inside the method, however (e.g., the method may internally call typeof(T2) and do something with that).

    If it was a typo, and the second parameter should read T2 p, then DaeMoohn is correct.


    UPDATE:

    If <T1> was there then all input
    arguments must be of type T1 and if
    <T1,T2> is there means all arguments
    must be of type either T1 or T2

    No! Inaccurate!

    The types of the parameters are specified right there in the parameter declaration: (T1 t, T1 p) — both must be of type T1 (just like if the parameters were declared (int x, int y) they’d both have to be int).

    Let’s look at that Accumulate signature:

    public static TSummary Accumulate <TInput, TSummary> (IEnumerable <TInput> coll, Action <TInput, TSummary> action)
    

    This method takes some sequence of TInput values (coll) and some delegate pointing to a method that accepts a TInput and a TSummary parameter (action). The method returns an object of type TSummary.

    What’s confusing about your first example is that one of the generic type arguments, T2, just happened not to be anywhere within the method signature itself. This simply means that T2 is not related to either the parameters or the return value. But it could still be used within the method.

    For example, consider this (fictional) method:

    string GetTypeName<T>();
    

    What does T mean in the above signature? It isn’t the return type (string), nor is it in the parameter list (there are none). So does it mean anything? Presumably, it indicates what type you want to get the name of. So internally the method would probably look like this:

    return typeof(T).FullName;
    

    The point here is that T2 in your first example must (if anything) affect only the internals of the method itself. Again: it is not related to the parameters or the return value.

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

Sidebar

Related Questions

Can someone help me understand how to write this case statement properly its not
Visual Studio 2008 C What I can't understand about this linked list is the
I don't understand why this statement in PHP echos 'whaaa?' -- (0x0F | 0xF0)
I understand this is an easy question but for some reason this just isn't
I understand this is a subjective question but I want to see how others
Hi I can't understand this error I want read this XML file: <?xml version=1.0
Note: I understand this is not strictly about development, but in the earlier threads
I'm still trying to understand KeyValuePairs but I believe this idea should work. In
I'm learning F# and finding I'm writing things that work but which I don't
I have a construction similar to this (but a lot more complicated): var list

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.