SlideShare a Scribd company logo
1 of 4
Download to read offline
C# Lambda Expression
 Lambda expressions use special syntax. They allow
functions to be used as data such as variables or
fields. The lambda expression syntax uses the =>
operator. This separates the parameters and
statement body of the anonymous function.
Example :~
 This program uses lambda expressions and other
anonymous functions. The source text uses the =>
operator. This is a syntax for separating the
parameters to a method from the statements in the
method's body.
 Tip: Lambda expressions use the token => in an
expression context. In this context, the token is not
a comparison operator.
Token :~
 The => operator can be read as "goes to" and it is
always used when declaring a lambda expression. A
lambda expression allows you to use a function with
executable statements as a parameter, variable or
field.
Methods :~
using System;
class Program
{
static void Main()
{
//
// Use implicitly typed lambda expression.
// ... Assign it to a Func instance.
//
Func<int, int> func1 = x => x + 1;
//
// Use lambda expression with statement body.
//
Func<int, int> func2 = x => {return x + 1; };
//
// Use formal parameters with expression body.
//
Func<int, int> func3 = (int x) => x + 1;
//
// Use parameters with a statement body.
//
Func<int, int> func4 = (int x) => { return x + 1; };
//
// Use multiple parameters.
//
Func<int, int, int> func5 = (x, y) => x * y;
//
// Use no parameters in a lambda expression.
//
Action func6 = () => Console.WriteLine();
//
// Use delegate method expression.
//
Func<int, int> func7 = delegate(int x) { return x + 1;
};
//
// Use delegate expression with no parameter list.
//
Func<int> func8 = delegate { return 1 + 1; };
// Invoke each of the lambda expressions and delegates
we created.
// ... The methods above are executed.
Console.WriteLine(func1.Invoke(1));
Console.WriteLine(func2.Invoke(1));
Console.WriteLine(func3.Invoke(1));
Console.WriteLine(func4.Invoke(1));
Console.WriteLine(func5.Invoke(2, 2));
func6.Invoke();
Console.WriteLine(func7.Invoke(1));
Console.WriteLine(func8.Invoke());
}
}
Output
2
2
2
2
4
2
2
In the example, we see the => syntax. This can be read as "goes
to." It separates the arguments from the method body of a lambda
expression. It is not a comparison operator. The => syntax
separates the left from the right.
Left side: This is an empty parameter list, a formal parameter list,
or an implicit parameter list from the body.
Right side: This can be a statement list inside curly brackets with
a return statement, or an expression.
C# LINQ
 LINQ. Imperative code describes how to complete an
algorithm.
It proceeds step by step, emphasizing process, not
result. Declarative code (like LINQ) describes the
end result
 This technology, Language Integrated Query,
introduces extension methods. These work on Lists
and arrays. We even use them on collections not yet
in memory.
 Example:We use the Average extension method to
average all the elements in an int array. A double
value is returned.
 Tip:The Average method is implemented as an
extension method within the .NET Framework.
Extension methods have special syntax.
Program that uses LINQ extension: C#
using System;
using System.Linq;
class Program
{
static void Main()
{
int[] array = { 1, 3, 5, 7 };
Console.WriteLine(array.Average());
}
}
Output
4

More Related Content

What's hot (20)

Storage Class Specifiers in C++
Storage Class Specifiers in C++Storage Class Specifiers in C++
Storage Class Specifiers in C++
 
Functions in c
Functions in cFunctions in c
Functions in c
 
C language presentation
C language presentationC language presentation
C language presentation
 
Lecture 11 - Functions
Lecture 11 - FunctionsLecture 11 - Functions
Lecture 11 - Functions
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
Lecture 14 - Scope Rules
Lecture 14 - Scope RulesLecture 14 - Scope Rules
Lecture 14 - Scope Rules
 
Anonymous and Inline Functions in MATLAB
Anonymous and Inline Functions in MATLABAnonymous and Inline Functions in MATLAB
Anonymous and Inline Functions in MATLAB
 
User Defined Functions in MATLAB Part-4
User Defined Functions in MATLAB Part-4User Defined Functions in MATLAB Part-4
User Defined Functions in MATLAB Part-4
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c language
 
Cpp functions
Cpp functionsCpp functions
Cpp functions
 
Learn Java Part 2
Learn Java Part 2Learn Java Part 2
Learn Java Part 2
 
Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
 
Storage class
Storage classStorage class
Storage class
 
C functions list
C functions listC functions list
C functions list
 
Function C++
Function C++ Function C++
Function C++
 
11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage class
 
Java 8
Java 8Java 8
Java 8
 
Storage class in c
Storage class in cStorage class in c
Storage class in c
 
Storage classes
Storage classesStorage classes
Storage classes
 
PLSQL CURSOR
PLSQL CURSORPLSQL CURSOR
PLSQL CURSOR
 

Viewers also liked

MTA animations graphics_accessing data
MTA animations graphics_accessing dataMTA animations graphics_accessing data
MTA animations graphics_accessing dataDhairya Joshi
 
Business and new economic enviornment
Business and new economic enviornment Business and new economic enviornment
Business and new economic enviornment Dhairya Joshi
 
Javascript regular expression
Javascript regular expressionJavascript regular expression
Javascript regular expressionDhairya Joshi
 
Software engg. pressman_ch-21
Software engg. pressman_ch-21Software engg. pressman_ch-21
Software engg. pressman_ch-21Dhairya Joshi
 
Chapter 8 switching -computer_network
Chapter 8   switching -computer_networkChapter 8   switching -computer_network
Chapter 8 switching -computer_networkDhairya Joshi
 
Chapter 5 analog transmission computer_network
Chapter 5 analog transmission  computer_networkChapter 5 analog transmission  computer_network
Chapter 5 analog transmission computer_networkDhairya Joshi
 
MTA managing the graphical interface by using css
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using cssDhairya Joshi
 
Website design principles
Website design principlesWebsite design principles
Website design principlesDhairya Joshi
 
MTA html5 text_graphics_media
MTA html5 text_graphics_mediaMTA html5 text_graphics_media
MTA html5 text_graphics_mediaDhairya Joshi
 
Software engg. pressman_ch-8
Software engg. pressman_ch-8Software engg. pressman_ch-8
Software engg. pressman_ch-8Dhairya Joshi
 

Viewers also liked (18)

Lecture1 oopj
Lecture1 oopjLecture1 oopj
Lecture1 oopj
 
Lecture6 oopj
Lecture6 oopjLecture6 oopj
Lecture6 oopj
 
MTA animations graphics_accessing data
MTA animations graphics_accessing dataMTA animations graphics_accessing data
MTA animations graphics_accessing data
 
Business and new economic enviornment
Business and new economic enviornment Business and new economic enviornment
Business and new economic enviornment
 
Javascript regular expression
Javascript regular expressionJavascript regular expression
Javascript regular expression
 
Css box model
Css box modelCss box model
Css box model
 
Software engg. pressman_ch-21
Software engg. pressman_ch-21Software engg. pressman_ch-21
Software engg. pressman_ch-21
 
MTA css layouts
MTA css layoutsMTA css layouts
MTA css layouts
 
Chapter 8 switching -computer_network
Chapter 8   switching -computer_networkChapter 8   switching -computer_network
Chapter 8 switching -computer_network
 
Lecture3 oopj
Lecture3 oopjLecture3 oopj
Lecture3 oopj
 
Chapter 5 analog transmission computer_network
Chapter 5 analog transmission  computer_networkChapter 5 analog transmission  computer_network
Chapter 5 analog transmission computer_network
 
Lecture9 oopj
Lecture9 oopjLecture9 oopj
Lecture9 oopj
 
MTA managing the graphical interface by using css
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using css
 
Website design principles
Website design principlesWebsite design principles
Website design principles
 
Lecture7 oopj
Lecture7 oopjLecture7 oopj
Lecture7 oopj
 
MTA html5 text_graphics_media
MTA html5 text_graphics_mediaMTA html5 text_graphics_media
MTA html5 text_graphics_media
 
Software engg. pressman_ch-8
Software engg. pressman_ch-8Software engg. pressman_ch-8
Software engg. pressman_ch-8
 
Ajax
Ajax Ajax
Ajax
 

Similar to Linq & lambda overview C#.net

Functions in C++
Functions in C++Functions in C++
Functions in C++home
 
All About ... Functions
All About ... FunctionsAll About ... Functions
All About ... FunctionsMichal Bigos
 
Amit user defined functions xi (2)
Amit  user defined functions xi (2)Amit  user defined functions xi (2)
Amit user defined functions xi (2)Arpit Meena
 
Lecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxLecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxKhurramKhan173
 
C#-LINQ-and-Lambda-Expression
C#-LINQ-and-Lambda-ExpressionC#-LINQ-and-Lambda-Expression
C#-LINQ-and-Lambda-ExpressionSimplilearn
 
Dti2143 chapter 5
Dti2143 chapter 5Dti2143 chapter 5
Dti2143 chapter 5alish sha
 
18 dec pointers and scope resolution operator
18 dec pointers and scope resolution operator18 dec pointers and scope resolution operator
18 dec pointers and scope resolution operatorSAFFI Ud Din Ahmad
 
Php Reusing Code And Writing Functions
Php Reusing Code And Writing FunctionsPhp Reusing Code And Writing Functions
Php Reusing Code And Writing Functionsmussawir20
 
Dev Concepts: Functional Programming
Dev Concepts: Functional ProgrammingDev Concepts: Functional Programming
Dev Concepts: Functional ProgrammingSvetlin Nakov
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 FunctionDeepak Singh
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.pptjaba kumar
 

Similar to Linq & lambda overview C#.net (20)

Functions
FunctionsFunctions
Functions
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Python_UNIT-I.pptx
Python_UNIT-I.pptxPython_UNIT-I.pptx
Python_UNIT-I.pptx
 
Fp201 unit5 1
Fp201 unit5 1Fp201 unit5 1
Fp201 unit5 1
 
All About ... Functions
All About ... FunctionsAll About ... Functions
All About ... Functions
 
Function in C++
Function in C++Function in C++
Function in C++
 
Amit user defined functions xi (2)
Amit  user defined functions xi (2)Amit  user defined functions xi (2)
Amit user defined functions xi (2)
 
Lecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxLecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptx
 
C#-LINQ-and-Lambda-Expression
C#-LINQ-and-Lambda-ExpressionC#-LINQ-and-Lambda-Expression
C#-LINQ-and-Lambda-Expression
 
Licão 13 functions
Licão 13 functionsLicão 13 functions
Licão 13 functions
 
Dti2143 chapter 5
Dti2143 chapter 5Dti2143 chapter 5
Dti2143 chapter 5
 
18 dec pointers and scope resolution operator
18 dec pointers and scope resolution operator18 dec pointers and scope resolution operator
18 dec pointers and scope resolution operator
 
Php Reusing Code And Writing Functions
Php Reusing Code And Writing FunctionsPhp Reusing Code And Writing Functions
Php Reusing Code And Writing Functions
 
Dev Concepts: Functional Programming
Dev Concepts: Functional ProgrammingDev Concepts: Functional Programming
Dev Concepts: Functional Programming
 
Javascript
JavascriptJavascript
Javascript
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 Function
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Linq & lambda overview C#.net

  • 1. C# Lambda Expression  Lambda expressions use special syntax. They allow functions to be used as data such as variables or fields. The lambda expression syntax uses the => operator. This separates the parameters and statement body of the anonymous function. Example :~  This program uses lambda expressions and other anonymous functions. The source text uses the => operator. This is a syntax for separating the parameters to a method from the statements in the method's body.  Tip: Lambda expressions use the token => in an expression context. In this context, the token is not a comparison operator. Token :~  The => operator can be read as "goes to" and it is always used when declaring a lambda expression. A lambda expression allows you to use a function with executable statements as a parameter, variable or field. Methods :~ using System; class Program { static void Main() { // // Use implicitly typed lambda expression. // ... Assign it to a Func instance.
  • 2. // Func<int, int> func1 = x => x + 1; // // Use lambda expression with statement body. // Func<int, int> func2 = x => {return x + 1; }; // // Use formal parameters with expression body. // Func<int, int> func3 = (int x) => x + 1; // // Use parameters with a statement body. // Func<int, int> func4 = (int x) => { return x + 1; }; // // Use multiple parameters. // Func<int, int, int> func5 = (x, y) => x * y; // // Use no parameters in a lambda expression. // Action func6 = () => Console.WriteLine(); // // Use delegate method expression. // Func<int, int> func7 = delegate(int x) { return x + 1; }; // // Use delegate expression with no parameter list. // Func<int> func8 = delegate { return 1 + 1; };
  • 3. // Invoke each of the lambda expressions and delegates we created. // ... The methods above are executed. Console.WriteLine(func1.Invoke(1)); Console.WriteLine(func2.Invoke(1)); Console.WriteLine(func3.Invoke(1)); Console.WriteLine(func4.Invoke(1)); Console.WriteLine(func5.Invoke(2, 2)); func6.Invoke(); Console.WriteLine(func7.Invoke(1)); Console.WriteLine(func8.Invoke()); } } Output 2 2 2 2 4 2 2 In the example, we see the => syntax. This can be read as "goes to." It separates the arguments from the method body of a lambda expression. It is not a comparison operator. The => syntax separates the left from the right. Left side: This is an empty parameter list, a formal parameter list, or an implicit parameter list from the body. Right side: This can be a statement list inside curly brackets with a return statement, or an expression.
  • 4. C# LINQ  LINQ. Imperative code describes how to complete an algorithm. It proceeds step by step, emphasizing process, not result. Declarative code (like LINQ) describes the end result  This technology, Language Integrated Query, introduces extension methods. These work on Lists and arrays. We even use them on collections not yet in memory.  Example:We use the Average extension method to average all the elements in an int array. A double value is returned.  Tip:The Average method is implemented as an extension method within the .NET Framework. Extension methods have special syntax. Program that uses LINQ extension: C# using System; using System.Linq; class Program { static void Main() { int[] array = { 1, 3, 5, 7 }; Console.WriteLine(array.Average()); } } Output 4