Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello. What exactly is the lambdas operator, and how should I define it in my head? For example:
x = y; //x is the same number as y.

if (x != y) //if x and y are different numbers do this, this, and this.
{
//this, this, and this
}
//How should I read this?
if (currentRoom.roomEnemies.Count(roomEnemies => roomEnemies != null) == 0)
{
Console.WriteLine("There are no enemies in here.");
}

Some more examples would be great. Thank you in advance.
Posted
Comments
[no name] 12-Jul-13 10:57am    
http://msdn.microsoft.com/en-us/library/vstudio/bb311046.aspx

1 solution

All a lambda is, is a method that has been "stretched out".
C#
x => x + 1;
Is the equivalent of writing
C#
private int MyMethod(int x)
   {
   return x + 1;
   }

There is a lot more to them than that when you come to using them (the whole of Linq depends on them for example) but for proper details, see MSDN: Lambda Expressions (C# Programming Guide)[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900