Solved

Please explain this lambda expression

Posted on 2010-08-18
5
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 27

Accepted Solution

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

Assisted Solution

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

Author Comment

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

Assisted Solution

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

Author Closing Comment

by:newbieweb
ID: 33467690
Thanks.
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Groupbox Control ? 2 39
T-SQL and CLR parameter strings 9 63
PowerShell: ForEach-Object Export to CSV 4 91
.NET Redemption/Outlook Examples 3 32
Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

732 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