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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:59:33+00:00 2026-05-11T21:59:33+00:00

I am at chapter 9 of Jon Skeet’s CSharp in Depth at a section

  • 0

I am at chapter 9 of Jon Skeet’s CSharp in Depth at a section which explains the improvements to type inference in 3.0

There is code snippet on Pg.247 that ‘shouldn’t compile with 2.0’ – However I can’t find a reason why it should not. Tried the problem with VS2008 C# Express Edition on a project with target framework as 2.0 – all three of the below calls compile and run too.

2.0 introduced the ability to infer the right type of delegate.

new List<ThreadStart>().Add( delegate { Console.WriteLine("New Thread!"); } );   // works

Of course Jon can’t be wrong ( 😉 ‘Sql is broken’ + there is no mention of this on the errata page for the book.) So my prime suspicion would be that it’s still using 3.0 type inference – What am I missing ?

    delegate int MyDelegate(string s);
    delegate TOutput MyConverter<TInput, TOutput>(TInput input);
    static void MyParse(MyDelegate del)
    {
        Console.WriteLine(del("100"));
    }
    static void MyConvert<TInput, TOutput>(MyConverter<TInput, TOutput> del, TInput input)
    {
        Console.WriteLine(del(input));
    }

    // Jon's code snippet begin
    delegate T MyFunc<T>();
    static void WriteResult<T>(MyFunc<T> function)
    {
        Console.WriteLine(function());
    }
    // end

    static void Main(string[] args)
    {
        MyParse(delegate(string s)
            {
                return Int32.Parse(s);
            }
        );
        MyConvert(delegate(string s)
            {
                return Int32.Parse(s);
            },
            "100");
        WriteResult(delegate { return 5; });    // Jon: Shouldn't work.
    }
  • 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-11T21:59:33+00:00Added an answer on May 11, 2026 at 9:59 pm

    What the ‘target framework’ setting does, is disable libraries and methods that have been added in newer framework versions. Most of the new language features don’t require special runtime support or new libraries. So if you use them, you need the newer compiler, but your app will still work on 2.0.

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

Sidebar

Related Questions

No related questions found

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.