How to get the first word from an array of strings with length of N using Linq in VB.NET

1 Answer

0 votes
Imports System
Imports System.Linq

Public Class Program
	Public Shared Sub Main()
        Dim array As String() = {"pro", "vb", "play", "sing", "sci", "fi", "game", 
								 "dev", "five", "moon", "c#", "net", "cool", "programming"}
        Dim length As Integer = 4
		
        Console.WriteLine(array.First(Function(word) word.Length = length))
    End Sub
End Class
	

	
	
' run:
'
' play
'

 



answered Jul 7, 2023 by avibootz
...