sashomaga

Lambda Select()

Feb 25th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. class Dog
  2.  
  3. {
  4.  
  5.       public string Name { get; set; }
  6.  
  7.       public int Age { get; set; }
  8.  
  9. }
  10.  
  11.  
  12.  
  13. static void Main()
  14.  
  15. {
  16.  
  17.       List<Dog> dogs = new List<Dog>()
  18.  
  19.       {
  20.  
  21.             new Dog { Name = "Rex", Age = 4 },
  22.  
  23.             new Dog { Name = "Sharo", Age = 0 },
  24.  
  25.             new Dog { Name = "Stasi", Age = 3 }
  26.  
  27.       };
  28.  
  29.       var names = dogs.Select(x => x.Name);
  30.  
  31.       foreach (var name in names)
  32.  
  33.       {
  34.  
  35.             Console.WriteLine(name);
  36.  
  37.       }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment