Mega Code Archive

 
Categories / VB.Net / LINQ
 

An indexed Where clause that returns digits whose name is shorter than their value

Imports System.IO Imports System.Reflection Imports System.Linq Imports System.Xml.Linq Public Class MainClass    Public Shared Sub Main         Dim digits = New String() {"zero", "one", "two"}         Dim shortDigits = digits.Where(Function(digit, index) digit.Length < index)         Console.WriteLine("Short digits:")         For Each d In shortDigits             Console.WriteLine("The word " & d & " is shorter than its value.")         Next    End Sub End Class