sashomaga

Lambda new

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