How to remove the last occurrence of comma from a string in VB.NET

1 Answer

0 votes
Imports System

Public Class Program
	Public Shared Sub Main()
        Dim s As String = "c c++, java, python, c# vb"
		
        Dim comma As String = ","
		
		Dim index As Integer = s.LastIndexOf(comma)
		
        s = If((index < 0), s, s.Remove(index, comma.Length))
			
        Console.Write(s)
    End Sub
End Class
	
	

	
	
' run:
'	
' c c++, java, python c# vb
'

 



answered Apr 18, 2022 by avibootz
...