7月17号msdn上看到的LINQ代码


    
    
    
    
  1. public void Linq5()
  2. {
  3.     string[] digits = { "zero""one""two""three""four""five""six""seven""eight""nine" };
  4.  
  5.     var shortDigits = digits.Where((digit, index) => digit.Length < index);
  6.  
  7.     Console.WriteLine("Short digits:");
  8.     foreach (var d in shortDigits)
  9.     {
  10.         Console.WriteLine("The word {0} is shorter than its value.", d);
  11.     }
  12. }

Result

Short digits:
The word five is shorter than its value.
The word six is shorter than its value.
The word seven is shorter than its value.
The word eight is shorter than its value.
The word nine is shorter than its value.

你可能感兴趣的:(职场,msdn,休闲)