Please explain this lambda expression

Posted on 2010-08-18
Medium Priority
Last Modified: 2013-12-17
 Thread t = new Thread ( () => Console.WriteLine ("Hello!") );

What version of C# (or .NET Framework) is needed for this to compile?

Is this an lambda expression which uses an anonymous method?

How would you explain exactly what this is?  I am new to LINQ and multi-threading...

Question by:newbieweb
  • 2
  • 2
LVL 27

Accepted Solution

nmarun earned 1332 total points
ID: 33467513
You need .net 3.0 to compile lambda expressions. Here's a nice article about lambda expressions.http://msdn.microsoft.com/en-us/library/bb397687.aspxArun
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 668 total points
ID: 33467528
That should compile on .Net 3.0 or above. A Lambda expression is essentially an anonymous method, so in this scenario it is being used in place of a ThreadStart delegate.

Author Comment

ID: 33467553
> A Lambda expression is essentially an anonymous method

is that true for all Lambda expressions?

Also, in this code, the body {} is basically the body of the anonymous method?

new Thread (() =>
  Console.WriteLine ("I'm running on another thread!");
  Console.WriteLine ("This is so easy!");
LVL 27

Assisted Solution

nmarun earned 1332 total points
ID: 33467598
Yes for the first question. And yes your understanding is right.Arun

Author Closing Comment

ID: 33467690

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question