當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET StringBuilder.Append方法代碼示例

本文整理匯總了VB.NET中System.Text.StringBuilder.Append方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET StringBuilder.Append方法的具體用法?VB.NET StringBuilder.Append怎麽用?VB.NET StringBuilder.Append使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Text.StringBuilder的用法示例。


在下文中一共展示了StringBuilder.Append方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1:

Dim sb As New System.Text.StringBuilder("The range of a 16-bit unsigned integer: ")
sb.Append(UInt16.MinValue).Append(" to ").Append(UInt16.MaxValue)
Console.WriteLine(sb)
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:3,代碼來源:StringBuilder.Append

輸出:

The range of a 16-bit unsigned integer: 0 to 65535

示例2:

Dim sb As New System.Text.StringBuilder("The range of a 32-bit unsigned integer: ")
sb.Append(UInt32.MinValue).Append(" to ").Append(UInt32.MaxValue)
Console.WriteLine(sb)
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:3,代碼來源:StringBuilder.Append

輸出:

The range of a 32-bit unsigned integer: 0 to 4294967295

示例3:

Dim sb As New System.Text.StringBuilder("The range of a 64-bit unsigned integer: ")
sb.Append(UInt64.MinValue).Append(" to ").Append(UInt64.MaxValue)
Console.WriteLine(sb)
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:3,代碼來源:StringBuilder.Append

輸出:

The range of a 64-bit unsigned integer: 0 to 18446744073709551615

示例4: chars

Dim chars() As Char = { "a"c, "b"c, "c"c, "d"c, "e"c}
Dim sb As New System.Text.StringBuilder()
Dim startPosition As Integer = Array.IndexOf(chars, "a"c)
Dim endPosition As Integer = Array.IndexOf(chars, "c"c)
If startPosition >= 0 AndAlso endPosition >= 0 Then
   sb.Append("The array from positions ").Append(startPosition).
             Append(" to ").Append(endPosition).Append(" contains ").
             Append(chars, startPosition, endPosition + 1).Append(".")
   Console.WriteLine(sb)
End If
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:10,代碼來源:StringBuilder.Append

輸出:

The array from positions 0 to 2 contains abc.

示例5:

Dim flag As Boolean = false
Dim sb As New System.Text.StringBuilder
sb.Append("The value of the flag is ").Append(flag).Append(".")
Console.WriteLine(sb.ToString())
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:4,代碼來源:StringBuilder.Append

輸出:

The value of the flag is False.

示例6:

Dim str As String = "First;George Washington;1789;1797"
Dim index As Integer = 0
Dim sb As New System.Text.StringBuilder()
Dim length As Integer = str.IndexOf(";"c, index)      
sb.Append(str, index, length).Append(" President of the United States: ")
index += length + 1
length = str.IndexOf(";"c, index) - index
sb.Append(str, index, length).Append(", from ")
index += length + 1
length = str.IndexOf(";"c, index) - index
sb.Append(str, index, length).Append(" to ")
index += length + 1
sb.Append(str, index, str.Length - index)
Console.WriteLine(sb)
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:14,代碼來源:StringBuilder.Append

輸出:

First President of the United States: George Washington, from 1789 to 1797

示例7:

Dim value As Decimal = 1346.19d
Dim sb As New System.Text.StringBuilder()
sb.Append("*"c, 5).AppendFormat("{0:C2}", value).Append("*"c, 5)
Console.WriteLine(sb)
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:4,代碼來源:StringBuilder.Append

輸出:

*****$1,346.19*****

示例8:

Dim sb As New System.Text.StringBuilder("The range of an 8-bit signed integer: ")
sb.Append(SByte.MinValue).Append(" to ").Append(SByte.MaxValue)
Console.WriteLine(sb)
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:3,代碼來源:StringBuilder.Append

輸出:

The range of an 8-bit unsigned integer: -128 to 127

示例9:

Dim value As Single = 1034769.47
Dim sb As New System.Text.StringBuilder()
sb.Append("*"c, 5).Append(value).Append("*"c, 5)
Console.WriteLine(sb)
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:4,代碼來源:StringBuilder.Append

輸出:

*****1034769.47*****

示例10:

Dim str As String = "Characters in a string."
Dim sb As New System.Text.StringBuilder()
For Each ch In str
   sb.Append(" '").Append(ch).Append("' ")
Next
Console.WriteLine("Characters in the string:")
Console.WriteLine("  {0}", sb)
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:7,代碼來源:StringBuilder.Append

輸出:

Characters in the string:
C'  'h'  'a'  'r'  'a'  'c'  't'  'e'  'r'  's'  ' '  'i'  'n'  ' '  'a'  ' '  's'  't' 'r'  'i'  'n'  'g'  '.'

示例11: chars

Dim chars() As Char = { "a"c, "e"c, "i"c, "o"c, "u"c }
Dim sb As New System.Text.StringBuilder()
sb.Append("The characters in the array: ").Append(chars)
Console.WriteLine(sb)
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:4,代碼來源:StringBuilder.Append

輸出:

The characters in the array: aeiou

示例12:

Dim value As Decimal = 1346.19d
Dim sb As New System.Text.StringBuilder()
sb.Append("*"c, 5).Append(value).Append("*"c, 5)
Console.WriteLine(sb)
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:4,代碼來源:StringBuilder.Append

輸出:

*****1346.19*****

示例13: bytes

Dim bytes() As Byte = { 16, 132, 27, 253 }
Dim sb As New System.Text.StringBuilder()
For Each value In bytes
   sb.Append(value).Append(" ")         
Next
Console.WriteLine("The byte array: {0}", sb.ToString())
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:6,代碼來源:StringBuilder.Append

輸出:

The byte array: 16 132 27 253

示例14:

Dim sb As New System.Text.StringBuilder("The range of a 16-bit integer: ")
sb.Append(Int16.MinValue).Append(" to ").Append(Int16.MaxValue)
Console.WriteLine(sb)
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:3,代碼來源:StringBuilder.Append

輸出:

The range of a 16-bit integer: -32768 to 32767

示例15:

Dim sb As New System.Text.StringBuilder("The range of a 32-bit integer: ")
sb.Append(Int32.MinValue).Append(" to ").Append(Int32.MaxValue)
Console.WriteLine(sb)
開發者ID:VB.NET開發者,項目名稱:System.Text,代碼行數:3,代碼來源:StringBuilder.Append

輸出:

The range of a 32-bit integer: -2147483648 to 2147483647


注:本文中的System.Text.StringBuilder.Append方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。