SlideShare a Scribd company logo
Presented By:
Malik Muzammil Nazir 20-Arid-332
Ashan Shahid 20-Arid-317
Aneeq Ahmed 20-Arid-3
Lambda expression in C#
â€ĸ C# 3.0 introduced the lambda expression.
â€ĸ It is also works like an anonymous method.
â€ĸ The difference that in Lambda expressions you don’t need to
specify the type of the value that you input thus making it
more flexible to use.
â€ĸ It means lambda expression simplifies the anonymous
function or you can say that lambda expression is a
shorthand for an anonymous function.
ANONYMOUS FUNCTION
â€ĸ We already discussed that delegates are used to reference any methods that has the
same signature as that of the delegate.
â€ĸ As the name suggests, an anonymous method is a method without a name just the body.
â€ĸ Anonymous methods in C# can be defined using the delegate keyword.
â€ĸ It is introduced in C# 2.0.
â€ĸ Anonymous method can be assigned to a variable of delegate type.
â€ĸ You need not specify the return type in an anonymous method; it is inferred from the
return statement inside the method body.
â€ĸ We don’t required to use access modifiers with anonymous function like public, private
etc.
â€ĸ We don’t required to use return type like int, string because its return type is set as
same as delegate type.
â€ĸ Anonymous function is not a static and instance member.
â€ĸ Points to Remember
â€ĸ Anonymous method can be defined using the delegate
keyword
â€ĸ Anonymous method must be assigned to a delegate.
â€ĸ Anonymous method can access outer variables or functions.
â€ĸ Anonymous method can be passed as a parameter.
â€ĸ Anonymous method can be used as event handlers.
ADVANTAGES OF ANONYMOUS FUNCTION IN C#
ADVANTAGES:
â€ĸ Lesser typing work because we don’t required to write access
modifier, return type and name of the function.
â€ĸ Anonymous functions are suggested when code volumes are less.
Anonymous Method Limitations:
â€ĸ It cannot contain jump statement like goto, break or continue.
â€ĸ It cannot access ref or out parameter of an outer method.
How to use:
The => is the lambda operator which
is used in all lambda expressions.
Types of Lambhda
â€ĸ The Lambda expression is divided into two parts, the left side is the input and
the right is the expression.
1. Statement Lambda: Consists of the input and a set of statements to be
executed.
Syntax
â€ĸ input => { statements };
2. Expression Lambda: Consists of the input and the expression.
Syntax
â€ĸ input => expression;
Source Code For Lambda Expression In C#
using System;
using System.Collections.Generic;
using System.Linq
;using System.Text;
using System.Threading.Tasks;
namespace LambdaExpressionDemo{ public delegate int MyDelegate(int num1, int num2);
class Program { static void Main(string[] args) {
MyDelegate obj = (a, b) => a + b;
Console.WriteLine(obj.Invoke(10,20));
int cube = obj1.Invoke(5);
Console.WriteLine(cube);
MyDelegate obj = (a) =>
{
a += 5;
return a;
}; //
Console.WriteLine(obj(5));
Console.ReadLine();
}}}
Thank You

More Related Content

Similar to Lamdha.pptx

Methods in C# | C# Methods Tutorial | C# Tutorial for Beginners | Learn C# Pr...
Methods in C# | C# Methods Tutorial | C# Tutorial for Beginners | Learn C# Pr...Methods in C# | C# Methods Tutorial | C# Tutorial for Beginners | Learn C# Pr...
Methods in C# | C# Methods Tutorial | C# Tutorial for Beginners | Learn C# Pr...
Simplilearn
 
15 anonymous methods, partial types and nullable types
15   anonymous methods, partial types and nullable types15   anonymous methods, partial types and nullable types
15 anonymous methods, partial types and nullable types
Tuan Ngo
 
Basic elements of java
Basic elements of java Basic elements of java
Basic elements of java
Ahmad Idrees
 
Lambdas, Collections Framework, Stream API
Lambdas, Collections Framework, Stream APILambdas, Collections Framework, Stream API
Lambdas, Collections Framework, Stream API
Prabu U
 
30csharp
30csharp30csharp
30csharp
Sireesh K
 
30c
30c30c
30c
Sireesh K
 
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya UdagedaraLambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Jaliya Udagedara
 
METHODS OR FUNCTIONS IN C for dotnet.pptx
METHODS OR FUNCTIONS IN C for dotnet.pptxMETHODS OR FUNCTIONS IN C for dotnet.pptx
METHODS OR FUNCTIONS IN C for dotnet.pptx
ArjunKhanal8
 
Explain Delegates step by step.
Explain Delegates step by step.Explain Delegates step by step.
Explain Delegates step by step.
Questpond
 
Java8 features
Java8 featuresJava8 features
Java8 features
Minal Maniar
 
Unit 1 psp
Unit 1 pspUnit 1 psp
Unit 1 psp
Karthi Vel
 
C#-LINQ-and-Lambda-Expression
C#-LINQ-and-Lambda-ExpressionC#-LINQ-and-Lambda-Expression
C#-LINQ-and-Lambda-Expression
Simplilearn
 
Compiler Design
Compiler Design Compiler Design
Compiler Design
PratushMishra
 
Learn C# programming - Program Structure & Basic Syntax
Learn C# programming - Program Structure & Basic SyntaxLearn C# programming - Program Structure & Basic Syntax
Learn C# programming - Program Structure & Basic Syntax
Eng Teong Cheah
 
Day02 01 Advance Feature in C# DH TDT
Day02 01 Advance Feature in C# DH TDTDay02 01 Advance Feature in C# DH TDT
Day02 01 Advance Feature in C# DH TDT
Nguyen Patrick
 
Module 2: C# 3.0 Language Enhancements (Slides)
Module 2: C# 3.0 Language Enhancements (Slides)Module 2: C# 3.0 Language Enhancements (Slides)
Module 2: C# 3.0 Language Enhancements (Slides)
Mohamed Saleh
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
Mani Kandan
 
Cs30 New
Cs30 NewCs30 New
Cs30 New
DSK Chakravarthy
 
Basic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartBasic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chart
Prasanna R Kovath
 
Presentation of computer
Presentation of computerPresentation of computer
Presentation of computer
SabinDhakal13
 

Similar to Lamdha.pptx (20)

Methods in C# | C# Methods Tutorial | C# Tutorial for Beginners | Learn C# Pr...
Methods in C# | C# Methods Tutorial | C# Tutorial for Beginners | Learn C# Pr...Methods in C# | C# Methods Tutorial | C# Tutorial for Beginners | Learn C# Pr...
Methods in C# | C# Methods Tutorial | C# Tutorial for Beginners | Learn C# Pr...
 
15 anonymous methods, partial types and nullable types
15   anonymous methods, partial types and nullable types15   anonymous methods, partial types and nullable types
15 anonymous methods, partial types and nullable types
 
Basic elements of java
Basic elements of java Basic elements of java
Basic elements of java
 
Lambdas, Collections Framework, Stream API
Lambdas, Collections Framework, Stream APILambdas, Collections Framework, Stream API
Lambdas, Collections Framework, Stream API
 
30csharp
30csharp30csharp
30csharp
 
30c
30c30c
30c
 
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya UdagedaraLambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
 
METHODS OR FUNCTIONS IN C for dotnet.pptx
METHODS OR FUNCTIONS IN C for dotnet.pptxMETHODS OR FUNCTIONS IN C for dotnet.pptx
METHODS OR FUNCTIONS IN C for dotnet.pptx
 
Explain Delegates step by step.
Explain Delegates step by step.Explain Delegates step by step.
Explain Delegates step by step.
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
Unit 1 psp
Unit 1 pspUnit 1 psp
Unit 1 psp
 
C#-LINQ-and-Lambda-Expression
C#-LINQ-and-Lambda-ExpressionC#-LINQ-and-Lambda-Expression
C#-LINQ-and-Lambda-Expression
 
Compiler Design
Compiler Design Compiler Design
Compiler Design
 
Learn C# programming - Program Structure & Basic Syntax
Learn C# programming - Program Structure & Basic SyntaxLearn C# programming - Program Structure & Basic Syntax
Learn C# programming - Program Structure & Basic Syntax
 
Day02 01 Advance Feature in C# DH TDT
Day02 01 Advance Feature in C# DH TDTDay02 01 Advance Feature in C# DH TDT
Day02 01 Advance Feature in C# DH TDT
 
Module 2: C# 3.0 Language Enhancements (Slides)
Module 2: C# 3.0 Language Enhancements (Slides)Module 2: C# 3.0 Language Enhancements (Slides)
Module 2: C# 3.0 Language Enhancements (Slides)
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
 
Cs30 New
Cs30 NewCs30 New
Cs30 New
 
Basic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartBasic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chart
 
Presentation of computer
Presentation of computerPresentation of computer
Presentation of computer
 

Recently uploaded

MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
ColÊgio Santa Teresinha
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
āĻŦāĻžāĻ‚āĻ˛āĻžāĻĻā§‡āĻļ āĻ…āĻ°ā§āĻĨāĻ¨ā§ˆāĻ¤āĻŋāĻ• āĻ¸āĻŽā§€āĻ•ā§āĻˇāĻž (Economic Review) ā§¨ā§Ļā§¨ā§Ē UJS App.pdf
āĻŦāĻžāĻ‚āĻ˛āĻžāĻĻā§‡āĻļ āĻ…āĻ°ā§āĻĨāĻ¨ā§ˆāĻ¤āĻŋāĻ• āĻ¸āĻŽā§€āĻ•ā§āĻˇāĻž (Economic Review) ā§¨ā§Ļā§¨ā§Ē UJS App.pdfāĻŦāĻžāĻ‚āĻ˛āĻžāĻĻā§‡āĻļ āĻ…āĻ°ā§āĻĨāĻ¨ā§ˆāĻ¤āĻŋāĻ• āĻ¸āĻŽā§€āĻ•ā§āĻˇāĻž (Economic Review) ā§¨ā§Ļā§¨ā§Ē UJS App.pdf
āĻŦāĻžāĻ‚āĻ˛āĻžāĻĻā§‡āĻļ āĻ…āĻ°ā§āĻĨāĻ¨ā§ˆāĻ¤āĻŋāĻ• āĻ¸āĻŽā§€āĻ•ā§āĻˇāĻž (Economic Review) ā§¨ā§Ļā§¨ā§Ē UJS App.pdf
eBook.com.bd (āĻĒā§āĻ°āĻ¯āĻŧā§‹āĻœāĻ¨ā§€āĻ¯āĻŧ āĻŦāĻžāĻ‚āĻ˛āĻž āĻŦāĻ‡)
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
A IndependÃĒncia da AmÊrica Espanhola LAPBOOK.pdf
A IndependÃĒncia da AmÊrica Espanhola LAPBOOK.pdfA IndependÃĒncia da AmÊrica Espanhola LAPBOOK.pdf
A IndependÃĒncia da AmÊrica Espanhola LAPBOOK.pdf
Jean Carlos Nunes PaixÃŖo
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 

Recently uploaded (20)

MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
āĻŦāĻžāĻ‚āĻ˛āĻžāĻĻā§‡āĻļ āĻ…āĻ°ā§āĻĨāĻ¨ā§ˆāĻ¤āĻŋāĻ• āĻ¸āĻŽā§€āĻ•ā§āĻˇāĻž (Economic Review) ā§¨ā§Ļā§¨ā§Ē UJS App.pdf
āĻŦāĻžāĻ‚āĻ˛āĻžāĻĻā§‡āĻļ āĻ…āĻ°ā§āĻĨāĻ¨ā§ˆāĻ¤āĻŋāĻ• āĻ¸āĻŽā§€āĻ•ā§āĻˇāĻž (Economic Review) ā§¨ā§Ļā§¨ā§Ē UJS App.pdfāĻŦāĻžāĻ‚āĻ˛āĻžāĻĻā§‡āĻļ āĻ…āĻ°ā§āĻĨāĻ¨ā§ˆāĻ¤āĻŋāĻ• āĻ¸āĻŽā§€āĻ•ā§āĻˇāĻž (Economic Review) ā§¨ā§Ļā§¨ā§Ē UJS App.pdf
āĻŦāĻžāĻ‚āĻ˛āĻžāĻĻā§‡āĻļ āĻ…āĻ°ā§āĻĨāĻ¨ā§ˆāĻ¤āĻŋāĻ• āĻ¸āĻŽā§€āĻ•ā§āĻˇāĻž (Economic Review) ā§¨ā§Ļā§¨ā§Ē UJS App.pdf
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
A IndependÃĒncia da AmÊrica Espanhola LAPBOOK.pdf
A IndependÃĒncia da AmÊrica Espanhola LAPBOOK.pdfA IndependÃĒncia da AmÊrica Espanhola LAPBOOK.pdf
A IndependÃĒncia da AmÊrica Espanhola LAPBOOK.pdf
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 

Lamdha.pptx

  • 1. Presented By: Malik Muzammil Nazir 20-Arid-332 Ashan Shahid 20-Arid-317 Aneeq Ahmed 20-Arid-3
  • 2. Lambda expression in C# â€ĸ C# 3.0 introduced the lambda expression. â€ĸ It is also works like an anonymous method. â€ĸ The difference that in Lambda expressions you don’t need to specify the type of the value that you input thus making it more flexible to use. â€ĸ It means lambda expression simplifies the anonymous function or you can say that lambda expression is a shorthand for an anonymous function.
  • 3. ANONYMOUS FUNCTION â€ĸ We already discussed that delegates are used to reference any methods that has the same signature as that of the delegate. â€ĸ As the name suggests, an anonymous method is a method without a name just the body. â€ĸ Anonymous methods in C# can be defined using the delegate keyword. â€ĸ It is introduced in C# 2.0. â€ĸ Anonymous method can be assigned to a variable of delegate type. â€ĸ You need not specify the return type in an anonymous method; it is inferred from the return statement inside the method body. â€ĸ We don’t required to use access modifiers with anonymous function like public, private etc. â€ĸ We don’t required to use return type like int, string because its return type is set as same as delegate type. â€ĸ Anonymous function is not a static and instance member.
  • 4. â€ĸ Points to Remember â€ĸ Anonymous method can be defined using the delegate keyword â€ĸ Anonymous method must be assigned to a delegate. â€ĸ Anonymous method can access outer variables or functions. â€ĸ Anonymous method can be passed as a parameter. â€ĸ Anonymous method can be used as event handlers.
  • 5. ADVANTAGES OF ANONYMOUS FUNCTION IN C# ADVANTAGES: â€ĸ Lesser typing work because we don’t required to write access modifier, return type and name of the function. â€ĸ Anonymous functions are suggested when code volumes are less. Anonymous Method Limitations: â€ĸ It cannot contain jump statement like goto, break or continue. â€ĸ It cannot access ref or out parameter of an outer method.
  • 6. How to use: The => is the lambda operator which is used in all lambda expressions.
  • 7. Types of Lambhda â€ĸ The Lambda expression is divided into two parts, the left side is the input and the right is the expression. 1. Statement Lambda: Consists of the input and a set of statements to be executed. Syntax â€ĸ input => { statements }; 2. Expression Lambda: Consists of the input and the expression. Syntax â€ĸ input => expression;
  • 8. Source Code For Lambda Expression In C# using System; using System.Collections.Generic; using System.Linq ;using System.Text; using System.Threading.Tasks; namespace LambdaExpressionDemo{ public delegate int MyDelegate(int num1, int num2); class Program { static void Main(string[] args) { MyDelegate obj = (a, b) => a + b; Console.WriteLine(obj.Invoke(10,20)); int cube = obj1.Invoke(5); Console.WriteLine(cube); MyDelegate obj = (a) => { a += 5; return a; }; // Console.WriteLine(obj(5)); Console.ReadLine(); }}}