文字列中の指定位置に文字列を挿入する方法を説明します。
String.Insert メソッドを使用する方法
1 2 3 |
Dim str As String = "ABCDE12345" Dim s1 As String = str.Insert(5, "あいう") |
StringBuilder.Insert メソッドを使用する方法
1 2 3 4 5 6 7 |
Dim str As String = "ABCDE12345" Dim sb As New System.Text.StringBuilder(str) '5文字目の後に文字列を挿入する sb.Insert(5, "あいう") Dim s1 As String = sb.ToString() |