How to find all 2 or 3 letters words from a list in VB.NET

1 Answer

0 votes
Imports System
Imports System.Linq
Imports System.Collections.Generic

Public Class Program
    Public Shared Sub Main(ByVal args As String())
        Dim lst As List(Of String) = New List(Of String) From {
            "python",
            "c",
            "c++",
            "c#",
            "java",
            "php",
			"vb",
            "nodejs",
            "ada",
            "go"
        }
		
        Dim threeLetter_words As List(Of String) = lst.Where(Function(word) word.Length = 2 OrElse word.Length = 3).ToList()
			
        Console.WriteLine(String.Join(", ", threeLetter_words))
    End Sub
End Class

 
   
   
' run:
'
' c++, c#, php, vb, ada, go
'

 



answered Jun 21, 2024 by avibootz

Related questions

1 answer 115 views
1 answer 145 views
1 answer 120 views
1 answer 100 views
2 answers 124 views
2 answers 178 views
...