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

2022年3月23日

書式
文字列.TrimEnd(CType(“,", Char))
TrimEndを使用して、文字列末尾の文字を削除します。

使用例

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

    Sub Main()

        '対象文字列
        Dim target As String = "study,skill,become,"

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

        Console.WriteLine(result)

        Console.ReadKey()
    End Sub

End Module

実行結果
study,skill,become

VB.net

Posted by arkgame