「VB.NET」StringBuilderのAppendメソッドで文字列を結合するサンプル

書式
Public Function Append(value As String) As StringBuilder
関数
Public Function Append (value As StringBuilder) As StringBuilder
指定された文字列ビルダーの文字列形式をこのインスタンスに追加します。
パラメーター
value 追加する文字列ビルダー。
戻り値 追加操作が完了した後のこのインスタンスへの参照。
StringBuilderクラスのappendメソッドで文字列を結合します。
appendメソッドで文字列を結合しています。
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Module Module1
Sub Main()
'文字列型
Dim strA As String = "study "
Dim strB As String = "skill "
Dim sb As New Text.StringBuilder
sb.Append(strA)
sb.Append(strB)
Console.WriteLine(sb)
'Integer型
Dim age As Integer = 35
sb.Append(age)
Console.WriteLine(sb)
'Double型
Dim sa As Double = 3.456
sb.Append(sa)
Console.WriteLine(sb)
Console.ReadKey()
End Sub
End Module
Module Module1 Sub Main() '文字列型 Dim strA As String = "study " Dim strB As String = "skill " Dim sb As New Text.StringBuilder sb.Append(strA) sb.Append(strB) Console.WriteLine(sb) 'Integer型 Dim age As Integer = 35 sb.Append(age) Console.WriteLine(sb) 'Double型 Dim sa As Double = 3.456 sb.Append(sa) Console.WriteLine(sb) Console.ReadKey() End Sub End Module
Module Module1

    Sub Main()
        '文字列型
        Dim strA As String = "study "
        Dim strB As String = "skill "

        Dim sb As New Text.StringBuilder
        sb.Append(strA)
        sb.Append(strB)
        Console.WriteLine(sb)

        'Integer型
        Dim age As Integer = 35
        sb.Append(age)
        Console.WriteLine(sb)

        'Double型
        Dim sa As Double = 3.456
        sb.Append(sa)
        Console.WriteLine(sb)

        Console.ReadKey()

    End Sub

End Module

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
study skill 
study skill 35
study skill 353.456
study skill  study skill 35 study skill 353.456
study skill 
study skill 35
study skill 353.456

 

VB.net

Posted by arkgame