Program that returns digits whose name is shorter than their value.

Amatya
Posted by Amatya under LINQ category on | Points: 40 | Views : 2453
Program that returns digits whose name is shorter than their value.

 public void DNF() 
{
string[] digitDNF = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };

var shortDNF = digitDNF.Where((digit, index) => digit.Length < index);

Console.WriteLine("Short DNF digits:");
foreach (var x in shortDNF )
{
Console.WriteLine("The word {0} is shorter than its value.", x);
}
}


Thanks
Amatya

Comments or Responses

Login to post response