What is the difference between lambdas and delegates?

Technology CommunityCategory: C#What is the difference between lambdas and delegates?
VietMX Staff asked 3 years ago

They are actually two very different things.

  • Delegate is actually the name for a variable that holds a reference to a method or a lambda, and a lambda is a method without a permanent name.
  • Lambdas are very much like other methods, except for a couple subtle differences:
  • A normal method is defined in a “statement” and tied to a permanent name, whereas a lambda is defined “on the fly” in an “expression” and has no permanent name.
  • Lambdas can be used with .NET expression trees, whereas methods cannot.