Solved

Please explain this lambda expression

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


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...

Thanks,
newbieweb
0
Comment
Question by:newbieweb
  • 2
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
nmarun earned 333 total points
Comment Utility
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
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 167 total points
Comment Utility
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.
0
 

Author Comment

by:newbieweb
Comment Utility
> 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!");
}).Start();
0
 
LVL 27

Assisted Solution

by:nmarun
nmarun earned 333 total points
Comment Utility
Yes for the first question. And yes your understanding is right.Arun
0
 

Author Closing Comment

by:newbieweb
Comment Utility
Thanks.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now