What does the sign "=>" stands for

minglelinch used Ask the Experts™
I have a piece of code contains the sign '=>' in C#. I do not understand what it stands for?  Thanks.

InObj = IO.InObj.Single(p => p.inObjId == Convert.ToInt32(Session["InObjID"]));
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Glanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015
It indicates you are using a lambda expression. It's almost like an anonymous function.
Top Expert 2009
It is the lambda operator, it means "goes to"


"goes to" in your example means

For (p) input, p goes to "p.inObjId == Convert.ToInt32(...)"

It is short hand for writing an anonymous closure, similar to

myclosure(p) {
   return p.inObjId == Convert.ToInt32(Session["InObjID"]));

Manoj PatilSr. Software Engineer
Lambda expression is an inline delegate introduced with C # 3.0 language. It’s a concise way to represent an anonymous method. It provides a syntax to create and invoke functions. Although Lambda expressions are simpler to use than anonymous methods, they do slightly differ on how they are implemented. Both anonymous methods and Lambda expressions allow you define the method implementation inline, however, an anonymous method explicitly requires you to define the parameter types and the return type for a method. Lambda expression uses the type inference feature of C# 3.0 which allows the compiler to infer the type of the variable based on the context.

Check Step by Step Implementation with explanation...


Thanks for all the commetns.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial