How to count the words in an array of strings 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() = {"c-sharp", "c", "vb.net", "java python go", "php javascript"}
		
        Dim totalWords = array.SelectMany(Function(e) e.Split(" "c)).Count()
			
        Console.WriteLine(totalWords)
    End Sub
End Class
	
	
	
' run:
' 
' 8
'

 



answered Jul 9, 2023 by avibootz
...