How to split a string and remove empty elements from result in VB.NET

1 Answer

0 votes
Imports System

Public Module Module1
    Public Sub Main()
		Dim str As String = "vb.net,, desktop,,, software, development"
	
		Dim arr() As String = str.Split(New Char() {","c}, StringSplitOptions.RemoveEmptyEntries)

        For Each element As String In arr
		Console.WriteLine(element.Trim())
        Next
    End Sub
End Module
 


 
 
' run:
'
' vb.net
' desktop
' software
' development
'

 



answered Oct 26, 2022 by avibootz
edited Oct 27, 2022 by avibootz
...