SlideShare a Scribd company logo
Language INtegrated Query
(LINQ)
Eng. Mahmoud Ouf
Lecture 1
mmouf@2017
C# 3.0 Enhancement for LINQ
• Implicitly Typed Local Variables and Arrays
• Object Initializers
• Auto Implemented Properties
• Collection Initializers
• Extension Methods
• Anonymous Types
mmouf@2017
Example
A Common Code developer wants to create a generic method for filtering an
array of integers, but with the ability to specify the algorithm for filtration to
the Application developer
mmouf@2017
Solution
• Solution
public delegate bool IntFilter(int i);
public class Common
{
public static int[] FilterArray(int[] ints, IntFilter filter)
{
ArrayList aList = new ArrayList();
foreach(int I in ints)
{
if(filter(i))
{aList.Add(i);}
}
return((int[])aList.ToArray(typeof(int)));
}
} mmouf@2017
The Application Code Developer (I)
Class MyApplication
{
public static bool IsOdd(int i)
{
return ((i % 2)==1);
}
public static void Main()
{
int[] nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int[] fnum = Common.FilterArray(nums, MyApplication.IsOdd);
foreach(int i in fnum)
Console.WriteLine(i);
}
}
mmouf@2017
The Application Code Developer Anonymous
method “C#2.0” (II)
Class MyApplication
{
public static void Main()
{
int[] nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int[] fnum = Common.FilterArray(nums, delegate(int i)
{return((i%2)==1);});
foreach(int i in fnum)
Console.WriteLine(i);
}
}
mmouf@2017

More Related Content

PDF
Intake 37 linq2
PDF
Intake 37 linq3
PDF
Intake 37 ef2
PDF
Intake 38 data access 3
PPT
Language Integrated Query By Nyros Developer
PPT
DOCX
Differences between method overloading and method overriding
Intake 37 linq2
Intake 37 linq3
Intake 37 ef2
Intake 38 data access 3
Language Integrated Query By Nyros Developer
Differences between method overloading and method overriding

What's hot (20)

PPT
Understanding linq
PPT
Module 3: Introduction to LINQ (PowerPoint Slides)
PDF
Intake 38 6
PDF
Intake 38_1
PDF
Intake 38 2
PPTX
Template C++ OOP
PDF
Intake 38 12
PDF
Intake 37 ef1
PDF
Introduction to C++
PPT
C++ Returning Objects
PDF
C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...
PDF
Intake 38 3
PPT
Templates
PPT
Language Integrated Query - LINQ
PDF
PDF
Intake 38 4
PDF
C++ questions And Answer
PPTX
Templates in c++
PPTX
Linq
PDF
CBSE Question Paper Computer Science with C++ 2011
Understanding linq
Module 3: Introduction to LINQ (PowerPoint Slides)
Intake 38 6
Intake 38_1
Intake 38 2
Template C++ OOP
Intake 38 12
Intake 37 ef1
Introduction to C++
C++ Returning Objects
C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...
Intake 38 3
Templates
Language Integrated Query - LINQ
Intake 38 4
C++ questions And Answer
Templates in c++
Linq
CBSE Question Paper Computer Science with C++ 2011
Ad

Viewers also liked (10)

PDF
2013_YOS Strategic Sustainability Plan progress_report
PDF
ekonomi spasial
PDF
Frederic Laloux Reinventing Organizations
PPTX
presentation reinventing organizations english frederic laloux
PPTX
A Missionary Detour: Heaven by Way of the Big Island
PPTX
Juguetenosexista t
PDF
The Product Owner's Survival Kit - ein Überblick [DE]
PPTX
Research methodology
PDF
GERENCIA DE PROYECTOS DE TECNOLOGÍA
PDF
Eqe 17 qualite_td_bin_2015_vdef
2013_YOS Strategic Sustainability Plan progress_report
ekonomi spasial
Frederic Laloux Reinventing Organizations
presentation reinventing organizations english frederic laloux
A Missionary Detour: Heaven by Way of the Big Island
Juguetenosexista t
The Product Owner's Survival Kit - ein Überblick [DE]
Research methodology
GERENCIA DE PROYECTOS DE TECNOLOGÍA
Eqe 17 qualite_td_bin_2015_vdef
Ad

Similar to Intake 37 linq1 (20)

PPTX
What's new in c# 8.0
PDF
Introduction to phyton , important topic
PPTX
Part - 2 Cpp programming Solved MCQ
PPTX
Presentation1 (1).pptx
PPTX
Introduction to Python.Net
PDF
ITI COPA Python MCQ Most Important New Question
PPTX
Constructor in c++
PDF
Getting started with C++
PDF
Getting Started with C++
PPTX
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
PPTX
Evolution of Patterns
PDF
Designing Architecture-aware Library using Boost.Proto
PDF
Interview-level-QA-on-Python-Programming.pdf
PDF
Functions in Pythons UDF and Functions Concepts
PPTX
Automation Testing theory notes.pptx
PPTX
Docketrun's Python Course for beginners.pptx
PDF
Cvpr2010 open source vision software, intro and training part-iii introduct...
PDF
C# 8 in Libraries and Applications
What's new in c# 8.0
Introduction to phyton , important topic
Part - 2 Cpp programming Solved MCQ
Presentation1 (1).pptx
Introduction to Python.Net
ITI COPA Python MCQ Most Important New Question
Constructor in c++
Getting started with C++
Getting Started with C++
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Evolution of Patterns
Designing Architecture-aware Library using Boost.Proto
Interview-level-QA-on-Python-Programming.pdf
Functions in Pythons UDF and Functions Concepts
Automation Testing theory notes.pptx
Docketrun's Python Course for beginners.pptx
Cvpr2010 open source vision software, intro and training part-iii introduct...
C# 8 in Libraries and Applications

More from Mahmoud Ouf (19)

PDF
Relation between classes in arabic
PDF
Intake 38 data access 5
PDF
Intake 38 data access 4
PDF
Intake 38 data access 1
PDF
Intake 38 11
PDF
Intake 38 10
PDF
Intake 38 9
PDF
Intake 38 8
PDF
Intake 38 7
PDF
Intake 38 5 1
PDF
Intake 38 5
PDF
Intake 37 DM
PDF
Intake 37 12
PDF
Intake 37 11
PDF
Intake 37 10
PDF
Intake 37 9
PDF
Intake 37 8
PDF
Intake 37 6
PDF
Intake 37 5
Relation between classes in arabic
Intake 38 data access 5
Intake 38 data access 4
Intake 38 data access 1
Intake 38 11
Intake 38 10
Intake 38 9
Intake 38 8
Intake 38 7
Intake 38 5 1
Intake 38 5
Intake 37 DM
Intake 37 12
Intake 37 11
Intake 37 10
Intake 37 9
Intake 37 8
Intake 37 6
Intake 37 5

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Encapsulation theory and applications.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
Cloud computing and distributed systems.
PPTX
MYSQL Presentation for SQL database connectivity
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Programs and apps: productivity, graphics, security and other tools
PPT
Teaching material agriculture food technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Review of recent advances in non-invasive hemoglobin estimation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Encapsulation theory and applications.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Spectroscopy.pptx food analysis technology
Unlocking AI with Model Context Protocol (MCP)
Per capita expenditure prediction using model stacking based on satellite ima...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The AUB Centre for AI in Media Proposal.docx
Reach Out and Touch Someone: Haptics and Empathic Computing
Building Integrated photovoltaic BIPV_UPV.pdf
cuic standard and advanced reporting.pdf
Cloud computing and distributed systems.
MYSQL Presentation for SQL database connectivity
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Programs and apps: productivity, graphics, security and other tools
Teaching material agriculture food technology
Chapter 3 Spatial Domain Image Processing.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

Intake 37 linq1

  • 1. Language INtegrated Query (LINQ) Eng. Mahmoud Ouf Lecture 1 mmouf@2017
  • 2. C# 3.0 Enhancement for LINQ • Implicitly Typed Local Variables and Arrays • Object Initializers • Auto Implemented Properties • Collection Initializers • Extension Methods • Anonymous Types mmouf@2017
  • 3. Example A Common Code developer wants to create a generic method for filtering an array of integers, but with the ability to specify the algorithm for filtration to the Application developer mmouf@2017
  • 4. Solution • Solution public delegate bool IntFilter(int i); public class Common { public static int[] FilterArray(int[] ints, IntFilter filter) { ArrayList aList = new ArrayList(); foreach(int I in ints) { if(filter(i)) {aList.Add(i);} } return((int[])aList.ToArray(typeof(int))); } } mmouf@2017
  • 5. The Application Code Developer (I) Class MyApplication { public static bool IsOdd(int i) { return ((i % 2)==1); } public static void Main() { int[] nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int[] fnum = Common.FilterArray(nums, MyApplication.IsOdd); foreach(int i in fnum) Console.WriteLine(i); } } mmouf@2017
  • 6. The Application Code Developer Anonymous method “C#2.0” (II) Class MyApplication { public static void Main() { int[] nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int[] fnum = Common.FilterArray(nums, delegate(int i) {return((i%2)==1);}); foreach(int i in fnum) Console.WriteLine(i); } } mmouf@2017