|
-
November 14th, 2010, 08:22 PM
#1
What does "()=>" mean?
Greetings!
A source code file for a .Net 3.5 application contains the following code in the beginning of an array definition:
A C# source code file I am hoping to use in a project of my own has an array definition that begins with the following code:
stf.ParseBlock(new STFReader.TokenProcessor[] {
new STFReader.TokenProcessor("eventtypelocation", ()=>{ stf.SkipBlock(); }),
What does the "()=>" mean? I've never seen that construct before.
Thanks very much!
RobR
-
November 14th, 2010, 08:30 PM
#2
Re: What does "()=>" mean?
I found it. => means "goes to" in a lambda expression. I am embarrassed that I didn't look in the C# help file before I posted here. My apologies for wasting bandwidth.
-
November 14th, 2010, 08:37 PM
#3
Re: What does "()=>" mean?
It's C#'s version of lambda functions, also called closures or anonymous functions.
Code:
delegate int myDelegate(int number);
delegate int myDelegate2(int number1, int number2);
myDelegate del = i => i + 1;
myDelegate2 del2 = (i, j) => i + j;
int a = del(42); // returns 43
int b = del2(42, 5); // returns 47
List<string> myStrings = new List<string>();
// Add Strings
myStrings.ForEach( i => Console.WriteLine(i) );
-
November 15th, 2010, 11:07 AM
#4
Re: What does "()=>" mean?
see this link to understand lamda expressions .. it's a part from linq to working with data in fast and easy way
-
November 15th, 2010, 09:59 PM
#5
Re: What does "()=>" mean?
 Originally Posted by ClassCoder
see this link to understand lamda expressions .. it's a part from linq to working with data in fast and easy way
Lambda expressions existed in .NET before LINQ did, though they are used heavily when using LINQ.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|