• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Please explain this lambda expression

 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
newbieweb
Asked:
newbieweb
  • 2
  • 2
3 Solutions
 
nmarunCommented:
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
 
Carl TawnSystems and Integration DeveloperCommented:
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
 
newbiewebAuthor Commented:
> 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
 
nmarunCommented:
Yes for the first question. And yes your understanding is right.Arun
0
 
newbiewebAuthor Commented:
Thanks.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now