「VB.NET」Insertメソッドで文字を挿入する方法

2021年10月4日

書式
文字列.Insert(挿入位置, 挿入文字)
文字列中の指定した位置に文字を挿入する
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Module Module1
Sub Main()
Dim str As String = "test"
Console.WriteLine("文字列: " + str)
'文字列.Insert(挿入位置,挿入文字)
Dim res As String = str.Insert(3, "abc")
Console.WriteLine("指定位置に文字を挿入後:" + res)
Console.ReadKey()
End Sub
End Module
Module Module1 Sub Main() Dim str As String = "test" Console.WriteLine("文字列: " + str) '文字列.Insert(挿入位置,挿入文字) Dim res As String = str.Insert(3, "abc") Console.WriteLine("指定位置に文字を挿入後:" + res) Console.ReadKey() End Sub End Module
Module Module1

    Sub Main()
        Dim str As String = "test"
        Console.WriteLine("文字列: " + str)

        '文字列.Insert(挿入位置,挿入文字)
        Dim res As String = str.Insert(3, "abc")
        Console.WriteLine("指定位置に文字を挿入後:" + res)

        Console.ReadKey()
    End Sub


End Module

実行結果
文字列: test
指定位置に文字を挿入後:tesabct

VB.net

Posted by arkgame