SlideShare uma empresa Scribd logo
1 de 6
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...
C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...
C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...
Rishikesh Agrawani
 
Language Integrated Query - LINQ
Language Integrated Query - LINQLanguage Integrated Query - LINQ
Language Integrated Query - LINQ
Doncho Minkov
 

Mais procurados (20)

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

Destaque

2013_YOS Strategic Sustainability Plan progress_report
2013_YOS Strategic Sustainability Plan progress_report2013_YOS Strategic Sustainability Plan progress_report
2013_YOS Strategic Sustainability Plan progress_report
Joy Sun
 

Destaque (10)

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

Semelhante a Intake 37 linq1

Introduction to phyton , important topic
Introduction to phyton , important topicIntroduction to phyton , important topic
Introduction to phyton , important topic
akpgenious67
 
Cvpr2010 open source vision software, intro and training part-iii introduct...
Cvpr2010 open source vision software, intro and training   part-iii introduct...Cvpr2010 open source vision software, intro and training   part-iii introduct...
Cvpr2010 open source vision software, intro and training part-iii introduct...
zukun
 
Function class in c++
Function class in c++Function class in c++
Function class in c++
Kumar
 

Semelhante a Intake 37 linq1 (20)

What's new in c# 8.0
What's new in c# 8.0What's new in c# 8.0
What's new in c# 8.0
 
Introduction to phyton , important topic
Introduction to phyton , important topicIntroduction to phyton , important topic
Introduction to phyton , important topic
 
Part - 2 Cpp programming Solved MCQ
Part - 2  Cpp programming Solved MCQ Part - 2  Cpp programming Solved MCQ
Part - 2 Cpp programming Solved MCQ
 
Presentation1 (1).pptx
Presentation1 (1).pptxPresentation1 (1).pptx
Presentation1 (1).pptx
 
Introduction to Python.Net
Introduction to Python.NetIntroduction to Python.Net
Introduction to Python.Net
 
Constructor in c++
Constructor in c++Constructor in c++
Constructor in c++
 
Getting started with C++
Getting started with C++Getting started with C++
Getting started with C++
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
 
ObliVM
ObliVMObliVM
ObliVM
 
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptxStatic abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
 
Evolution of Patterns
Evolution of PatternsEvolution of Patterns
Evolution of Patterns
 
Designing Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.ProtoDesigning Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.Proto
 
Interview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdfInterview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdf
 
Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptx
 
Cvpr2010 open source vision software, intro and training part-iii introduct...
Cvpr2010 open source vision software, intro and training   part-iii introduct...Cvpr2010 open source vision software, intro and training   part-iii introduct...
Cvpr2010 open source vision software, intro and training part-iii introduct...
 
C# 8 in Libraries and Applications
C# 8 in Libraries and ApplicationsC# 8 in Libraries and Applications
C# 8 in Libraries and Applications
 
Python
PythonPython
Python
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
 
Function class in c++
Function class in c++Function class in c++
Function class in c++
 
Defaultification Refactoring: A Tool for Automatically Converting Java Method...
Defaultification Refactoring: A Tool for Automatically Converting Java Method...Defaultification Refactoring: A Tool for Automatically Converting Java Method...
Defaultification Refactoring: A Tool for Automatically Converting Java Method...
 

Mais de Mahmoud Ouf (19)

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

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
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
 

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