2008年12月16日 星期二

StringBuilder Sample

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '使用String
        Dim str1 = "王先生"
        str1 = str1 & vbNewLine
        str1 = str1 & "您好"
        MsgBox(str1)

        '使用StringBuilder
        Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder
        sb.AppendLine("王先生")
        sb.Append("您好")
        MsgBox(sb.ToString)
    End Sub
End Class

沒有留言: