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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:17:27+00:00 2026-05-15T18:17:27+00:00

class Program { static void Main(string[] args) { Type t = typeof(A<,>); Console.WriteLine(typeof(A<,>)); //

  • 0
class Program
{
    static void Main(string[] args)
    {
        Type t = typeof(A<,>);
        Console.WriteLine(typeof(A<,>)); // prints A'2[T1,T2]
    }    
}

class A<T1,T2>
{

}

As far as I know, generic type A<T1, T2> is not an actual type, but rather a blueprint/template for an actual type, so why does typeof accept it as a parameter (since as far as I know, typeof accepts as parameter actual types)?

Thank you

  • 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-15T18:17:27+00:00Added an answer on May 15, 2026 at 6:17 pm

    In reflection the unconstructed generic type, say C<> is conflated with the instance type C<T>.

    This is perhaps less than theoretically pure; I think of these as very different entities. I think of one as the symbol “C with one type parameter” and the other as a compile time type C<T>. In code, C<> and C<T> are not synonyms for each other; you can make a field of the latter type if T is in scope, but you cannot ever make a field of the former type.

    That the reflection library gives you the type of the instance type when you ask for the unconstructed type is not all bad though. What would you do with the unconstructed type? There’s nothing you really can do with it. But with the instance type, you can say “substitute int for T” in here.

    The real benefit of getting C<T> when you ask for typeof(C<>) is that this always gives you the unconstructed type. Compare:

    class C<T>
    {
        public static Type CT() { return typeof(C<T>); }
        public static Type JustC() { return typeof(C<>); }
    }
    

    When you call CT, what are you going to call it on? There’s no type C<T> to call CT on. You can call C<int>.CT in which case you’ll get back C<int>, not C<T>. The only way to get the type C<> constructed with T is to ask for typeof(C<>).

    Does that make sense?

    I haven’t yet covered reflection ( I have a vague idea of what it is )

    Reflection is simply the library of code that allows you to get information about your code in the code itself. “typeof” gives you a Type object which you can then “reflect” upon to find out information about the type.

    I’m not sure I understand what you mean by “even when T is not in scope”

    The way I said it was confusing. I’ve rephrased it.

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

Sidebar

Ask A Question

Stats

  • Questions 532k
  • Answers 532k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The App Engine datastore isn't capable of doing a query… May 17, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer The correct regex is no regex. Use an HTML/DOM Parser… May 17, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer That's what OSGi is for. And Equinox a small nice… May 17, 2026 at 12:15 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

class Program { static void Main(string[] args) { string value = "12345"; Type enumType
I have the following code: class Program { static void Main(string[] args) { string
I have a generic abstract base class from which I would like to derive
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; namespace ConsoleApplication2 { class
I have been looking at Reflection.Emit recently. I wrote a simple program that generates
If I want to get a user input from Console to my Expression Tree.
When reflecting on an interface type, I only get the members of the specific
The following program works correctly. However, I would like to change it to not
I need to add numerous variables of type nullable int. I used the null
How could I compile a .cs program that references a COM DLL from 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.