• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了VB.NET中System.Text.StringBuilder.Append方法的典型用法代码示例。如果您正苦于以下问题:VB.NET StringBuilder.Append方法的具体用法?VB.NET StringBuilder.Append怎么用?VB.NET StringBuilder.Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Text.StringBuilder的用法示例。



在下文中一共展示了StringBuilder.Append方法的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16:

Dim sb As New System.Text.StringBuilder("The range of a 64-bit integer: ")
sb.Append(Int64.MinValue).Append(" to ").Append(Int64.MaxValue)
Console.WriteLine(sb)
开发者ID:VB.NET开发者,项目名称:System.Text,代码行数:3,代码来源:StringBuilder.Append

输出:

The range of a 64-bit integer:  -9223372036854775808 to 9223372036854775807


示例17: Dog

Public Class Dog
   Private dogBreed As String
   Private dogName As String
   
   Public Sub New(name As String, breed As String)
      Me.dogName = name
      Me.dogBreed = breed
   End Sub
   
   Public ReadOnly Property Breed As String
      Get
         Return Me.dogBreed
      End Get
   End Property
   
   Public ReadOnly Property Name As String
      Get
         Return Me.dogName
      End Get
   End Property
   
   Public Overrides Function ToString() As String
      Return Me.dogName
   End Function
End Class
   
Module Example
   Public Sub Main()
      Dim dog1 As New Dog("Yiska", "Alaskan Malamute")
      Dim sb As New System.Text.StringBuilder()     
      sb.Append(dog1).Append(", Breed: ").Append(dog1.Breed)  
      Console.WriteLine(sb)
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Text,代码行数:34,代码来源:StringBuilder.Append

输出:

Yiska, Breed: Alaskan Malamute


示例18:

Dim value As Double = 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*****


示例19: MainClass

' 导入命名空间
Imports System
Imports System.Text

Public Class MainClass

   Shared Sub Main()
      Dim objectValue As Object = "hello"
      Dim stringValue As String = "good bye"
      Dim characterArray As Char() = {"a"c, "b"c, "c"c, _
         "d"c, "e"c, "f"c}

      Dim booleanValue As Boolean = True
      Dim characterValue As Char = "Z"c
      Dim integerValue As Integer = 2347
      Dim longValue As Long = 100
      Dim singleValue As Single = 2.52
      Dim doubleValue As Double = 3.3
      Dim buffer As StringBuilder = New StringBuilder()

      ' use method Append to append values to buffer
      buffer.Append(objectValue)
      buffer.Append("  ")
      buffer.Append(stringValue)
      buffer.Append("  ")
      buffer.Append(characterArray)
      buffer.Append("  ")
      buffer.Append(characterArray, 0, 3)
      buffer.Append("  ")
      buffer.Append(booleanValue)
      buffer.Append("  ")
      buffer.Append(characterValue)
      buffer.Append("  ")
      buffer.Append(integerValue)
      buffer.Append("  ")
      buffer.Append(longValue)
      buffer.Append("  ")
      buffer.Append(singleValue)
      buffer.Append("  ")
      buffer.Append(doubleValue)

      Console.WriteLine("buffer = " & buffer.ToString())   
  End Sub ' Main

End Class
开发者ID:VB程序员,项目名称:System.Text,代码行数:45,代码来源:StringBuilder.Append



注:本文中的System.Text.StringBuilder.Append方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
VB.NET StringBuilder.CopyTo方法代码示例发布时间:2022-05-24
下一篇:
VB.NET Encoding.GetPreamble方法代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap