Title: What is the purpose of "()=>"
Tags: c#
Question: I haven't really come across this syntax during my Programming classes in Uni before and I'm curious as to what it means.
The only times I've had to implement it was:
When I had to create a BackgroundWorker that had to be added to the ProgressChanged event
Invoke((MethodInvoker)(() =&gt; updatePing((int) e.UserState)));
When researching tutorials on using the Caliburn.Micro MVVM framework
NotifyOfPropertyChange(() =&gt; Count);
I have tried searching around on what this notation means but the special characters it uses seem to mess with google search and I have no idea what it is called.
Comment: Searching for `"=>"` works OK.

Comment: It introduces a no-argument lambda expression (which is convertible to a no-argument `Action` or `Func` delegate, depending on its content.) It's basically shorthand for creating an anonymous function (though it's actually more powerful than that.) Read about them here: http://msdn.microsoft.com/en-us/library/bb397687.aspx

Comment: Ah, there we go, see I didn't know it was called a lambda expression and searching `=>` wouldn't yield any results.

Here is the accepted answer: The =&gt; is syntax for a lambda expression.
The () signifies that there are no parameters - if there were parameters and the types could be inferred from context, they could be specified as something like this:
(x, y) =&gt; x + y
Or specifying the types explicitly
(int x, string y) =&gt; x + y.Length
If there's only one parameter and its type can be inferred, you don't need the brackets:
x =&gt; x.Length

Here is another answer: that's a lambda expression with no parameters.
What you're really doing, is passing a delegate(which is sorta like a variable for methods) into your function
() =&gt; Count represents a method resembling the following
type methodName()
return Count;
Comment for this answer: It also lets you do more complicated logic. For example, if the method you're passing the lambda to is asynchronous, the lambda expression could represent an entire callback function, like this: `doSomeExpensiveAsyncMethod(x, y, () => dialog.TellUserThatOperationIsFinished())`.
Comment for this answer: So what is the difference between `() => Count`, and just passing `Count`
Comment for this answer: @ChaoticLoki it matters if `Count` gets changed after you pass the delegate, but before you actually invoke it.  If you just pass `Count` than it will return what count was when you passed it.
Comment for this answer: @RichardJ.RossIII  Funny thing is, It almost seems like Jon Skeet's very presence is pulling additional traffic into this question, causing my answer to be up-voted more than it would have been had he not posted here.
Comment for this answer: You got skeet'd.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 3, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:05/15/13', 'FavoriteCount': 2.0, 'PostTypeId': 1, 'Tags': '<c#>', 'Title': 'What is the purpose of "()=>"', 'ViewCount': 379, 'id': 16571680, 'user_AboutMe': '', 'user_AccountId': 1803461.0, 'user_DisplayName': 'clifford.duke', 'user_Reputation': 3890.0, 'user_Views': 372.0, 'user_id': 1712587.0}}