How to calculate the average length of the strings in string array with VB.NET

1 Answer

0 votes
Imports System
Imports System.Linq

Public Class CalculateAverageLengthOfStringsInStringArray_VB_NET
	Public Shared Sub Main(ByVal args As String())
        Dim arr As String() = {"vb", "c", "c++", "java", "python"}
		
        Dim average As Double = arr.Average(Function(x) x.Length)
			
        Console.WriteLine(average)
    End Sub
End Class



' run:
'
' 3.2
'

 



answered Aug 19, 2024 by avibootz
...