「VB.NET」TrimEnd関数で文字列末尾の文字を削除する

書式
対象文字列.TrimEnd(CType(“,", Char))
文字列の末尾のカンマを削除します
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Module Module1
Public Sub Main()
'対象文字列
Dim strA As String = "study,skill,become,"
Console.WriteLine("カンマ削除前: " & strA)
'末尾のカンマを削除
Dim result As String = strA.TrimEnd(CType(",", Char))
Console.WriteLine("カンマ削除後: " & result)
Console.ReadKey()
End Sub
End Module
Module Module1 Public Sub Main() '対象文字列 Dim strA As String = "study,skill,become," Console.WriteLine("カンマ削除前: " & strA) '末尾のカンマを削除 Dim result As String = strA.TrimEnd(CType(",", Char)) Console.WriteLine("カンマ削除後: " & result) Console.ReadKey() End Sub End Module
Module Module1

    Public Sub Main()

        '対象文字列
        Dim strA As String = "study,skill,become,"
        Console.WriteLine("カンマ削除前: " & strA)

        '末尾のカンマを削除
        Dim result As String = strA.TrimEnd(CType(",", Char))

        Console.WriteLine("カンマ削除後: " & result)

        Console.ReadKey()
    End Sub

End Module

実行結果
カンマ削除前: study,skill,become,
カンマ削除後: study,skill,become

VB.net

Posted by arkgame