nKolchakoV

Untitled

Feb 13th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _03.FindStudentsLINQ
  8. {
  9.     class Program
  10.     {
  11.         static void Main()
  12.         {
  13.             Student[] students =
  14.             {
  15.                 new Student
  16.                 {
  17.                     FirstName = "Ivan",
  18.                     LastName = "Tomov"
  19.                 },
  20.  
  21.                 new Student
  22.                 {
  23.                     FirstName = "Todor",
  24.                     LastName = "Marinov"
  25.                 },
  26.  
  27.                 new Student
  28.                 {
  29.                     FirstName = "Ivaylo",
  30.                     LastName = "Kostov"
  31.                 },
  32.  
  33.                 new Student
  34.                 {
  35.                     FirstName = "Nikolay",
  36.                     LastName = "Angelov"  
  37.                 },
  38.                  new Student
  39.                 {
  40.                     FirstName = "Alexander",
  41.                     LastName = "Borisov"  
  42.                 },
  43.             };
  44.            
  45.  
  46.             var firstNameBeforLast = students
  47.                 .Where(st => st.FirstName[0] < st.LastName[0])
  48.                 .Select(st => new
  49.                 {
  50.                    FirstName = st.FirstName,
  51.                    LastName = st.LastName
  52.            
  53.                 });
  54.  
  55.             foreach (var item in firstNameBeforLast)
  56.             {
  57.                 Console.WriteLine(item);
  58.             }
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment