Lecture overview -- Keyboard shortcut: 'u'  Previous page: Map, filter, and reduce -- Keyboard shortcut: 'p'  Next page: An overview of some LINQ Query Operators -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Page 4 : 11
Object-oriented Programming in C#
An Introduction to LINQ
Basic LINQ Examples

Queries on a number of Person objects

    new List<Person>{
     new Person{FName="Pippi", LName="Pi",   Age=25, Sex = Sex.Female},
     new Person{FName="Lone",  LName="Rho",  Age=51, Sex = Sex.Female},
     new Person{FName="Anni",  LName="Lyng", Age=36, Sex = Sex.Female},
     new Person{FName="Martin",LName="Beck", Age=57, Sex = Sex.Male},
     new Person{FName="Per",   LName="Birk", Age=47, Sex = Sex.Male},
     new Person{FName="Stig",  LName="Malm", Age=50, Sex = Sex.Male} 

Sample Data - short form.

/user/normark/oop-csharp-1/sources/c-sharp/linq/data.csSample data - Class Persons and a collection of persons.

/user/normark/oop-csharp-1/sources/c-sharp/linq/ex1.csThe average age of all females.

/user/normark/oop-csharp-1/sources/c-sharp/linq/ex2.csThe average age of all females - basic version.

/user/normark/oop-csharp-1/sources/c-sharp/linq/ex3.csA comma-separated list of all male first names, youngest first.

/user/normark/oop-csharp-1/sources/c-sharp/linq/ex4.csA sequence of female-male pairs sequences.

/user/normark/oop-csharp-1/sources/c-sharp/linq/ex4A.csSame - using flattening SelecteMany.

/user/normark/oop-csharp-1/sources/c-sharp/linq/ex4-outputEquivalent output of last two programs: all femal-male pairs.