当前位置: 首页>>代码示例>>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;未经允许,请勿转载。