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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:57:18+00:00 2026-05-26T16:57:18+00:00

Normally getting an unconstructed generic type is quite easy, using typeof : Type genericType

  • 0

Normally getting an unconstructed generic type is quite easy, using typeof:

Type genericType = typeof( Func<> );

I would expect the following to work as well, but it gives a compiler error Type expected.

Type genericNestedType = typeof( Func<Func<>> );

It’s relatively easy to work around this by using Func<Func<object>> instead. However, where you ‘consume’ the type you then have to remember calling GetGenericTypeDefinition().

A scenario where you would want to ‘fill up’ all non-assigned generic type parameters wouldn’t be possible. Again, it would be relatively easy to create a dummy type instead to indicate those parameters. (e.g. Func<Func<ToReplace, object, int>>)

Is there any reason why typeof doesn’t work on nested generic unconstructed types?

  • 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-26T16:57:19+00:00Added an answer on May 26, 2026 at 4:57 pm

    I don’t believe this is a compiler bug – section 7.6.11 of the C# 4 spec (the typeof operator) doesn’t seem to give any syntax which would lead it to be valid; Func<Func<>> is neither a valid type construction, nor a valid unbound-type-name construction.

    As to why that’s the case though: my guess is that it’s very rarely needed (I’ve never even thought of using it before, nor heard anyone requesting it) and so the additional complexity in language design, compiler implementation and testing has been considered to outweigh the benefit. This is often the case with “why doesn’t C# have feature X” questions, as Eric Lippert is fond of pointing out 🙂

    I was pleasantly surprised to see that it is possible to do at execution time:

    Type unbound = typeof(Func<>);
    Type partiallyBound = unbound.MakeGenericType(new[] { unbound });
    Console.WriteLine(partiallyBound);        
    

    I was half expecting it to be invalid in the .NET type system, although I expect that could have caused other problems.

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

Sidebar

Related Questions

Normally when using VMWare Server 1.0.7 you are asked if you would like to
I'm having a fundamental problem with getting scrolling to work normally on my iPhone
I am using hibernate 3.6, normally annotation comes in 3.6 but i am getting
Normally when getting the offset using jQuery I do offset().left . My understanding is
I am having trouble getting rand() to work in C++. rand() normally gives me
After everything running normally for a few weeks, we're suddenly getting the following message
Normally you create a function using cfscript like: <cfscript> function foo() { return bar;
Normally you can do this: <select size=3> <option>blah</option> <option>blah</option> <option>blah</option> </select> And it would
Normally, in Delphi one would declare a function with a variable number of arguments
Normally to attach a debuger to a running jvm you would need start 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.