Use an indexed Where clause (where the length of the number's name is shorter than its value) : Index : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » Index »

 

Use an indexed Where clause (where the length of the number's name is shorter than its value)








    
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass {
    public static void Main() {

        string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };

        var shortDigits = digits.Where((digit, index) => digit.Length < index);

        foreach (var d in shortDigits) {
            Console.WriteLine("The word {0} is shorter than its value.", d);
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» Index