StringBuilder.Append StringBuilder.Append StringBuilder.Append StringBuilder.Append Method

定義

將指定物件的字串表示附加至這個執行個體。Appends the string representation of a specified object to this instance.

多載

Append(StringBuilder) Append(StringBuilder) Append(StringBuilder) Append(StringBuilder)

將指定字串產生器的字串表示附加至這個執行個體。Appends the string representation of a specified string builder to this instance.

Append(UInt16) Append(UInt16) Append(UInt16) Append(UInt16)

將指定的 16 位元不帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 16-bit unsigned integer to this instance.

Append(UInt32) Append(UInt32) Append(UInt32) Append(UInt32)

將指定的 32 位元不帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 32-bit unsigned integer to this instance.

Append(UInt64) Append(UInt64) Append(UInt64) Append(UInt64)

將指定的 64 位元不帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 64-bit unsigned integer to this instance.

Append(Char[], Int32, Int32) Append(Char[], Int32, Int32) Append(Char[], Int32, Int32) Append(Char[], Int32, Int32)

將 Unicode 字元之指定子陣列的字串表示附加至這個執行個體。Appends the string representation of a specified subarray of Unicode characters to this instance.

Append(Char*, Int32) Append(Char*, Int32) Append(Char*, Int32)

將指定位址開頭的 Unicode 字元陣列附加至這個執行個體。Appends an array of Unicode characters starting at a specified address to this instance.

Append(String) Append(String) Append(String) Append(String)

將指定字串的複本附加至這個執行個體。Appends a copy of the specified string to this instance.

Append(String, Int32, Int32) Append(String, Int32, Int32) Append(String, Int32, Int32) Append(String, Int32, Int32)

將指定子字串的複本附加至這個執行個體。Appends a copy of a specified substring to this instance.

Append(StringBuilder, Int32, Int32) Append(StringBuilder, Int32, Int32) Append(StringBuilder, Int32, Int32) Append(StringBuilder, Int32, Int32)

將所指定字串產生器內的子字串複本附加至這個執行個體。Appends a copy of a substring within a specified string builder to this instance.

Append(Char, Int32) Append(Char, Int32) Append(Char, Int32) Append(Char, Int32)

將 Unicode 字元其字串表示的指定複本數附加至這個執行個體。Appends a specified number of copies of the string representation of a Unicode character to this instance.

Append(SByte) Append(SByte) Append(SByte) Append(SByte)

將指定的 8 位元帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 8-bit signed integer to this instance.

Append(Single) Append(Single) Append(Single) Append(Single)

將指定的單精確度浮點數之字串表示附加至這個執行個體。Appends the string representation of a specified single-precision floating-point number to this instance.

Append(ReadOnlyMemory<Char>) Append(ReadOnlyMemory<Char>) Append(ReadOnlyMemory<Char>) Append(ReadOnlyMemory<Char>)

將所指定唯讀字元記憶體區域的字串表示附加至這個執行個體。Appends the string representation of a specified read-only character memory region to this instance.

Append(Boolean) Append(Boolean) Append(Boolean) Append(Boolean)

將指定的布林 (Boolean) 值之字串表示附加至這個執行個體。Appends the string representation of a specified Boolean value to this instance.

Append(ReadOnlySpan<Char>) Append(ReadOnlySpan<Char>) Append(ReadOnlySpan<Char>) Append(ReadOnlySpan<Char>)

將所指定唯讀字元範圍的字串表示附加至這個執行個體。Appends the string representation of a specified read-only character span to this instance.

Append(Char) Append(Char) Append(Char) Append(Char)

將指定 Char 物件的字串表示附加至這個執行個體。Appends the string representation of a specified Char object to this instance.

Append(Char[]) Append(Char[]) Append(Char[]) Append(Char[])

將指定陣列中的 Unicode 字元的字串表示附加至這個執行個體。Appends the string representation of the Unicode characters in a specified array to this instance.

Append(Decimal) Append(Decimal) Append(Decimal) Append(Decimal)

將指定的小數位數之字串表示附加至這個執行個體。Appends the string representation of a specified decimal number to this instance.

Append(Byte) Append(Byte) Append(Byte) Append(Byte)

將指定的 8 位元不帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 8-bit unsigned integer to this instance.

Append(Int16) Append(Int16) Append(Int16) Append(Int16)

將指定的 16 位元帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 16-bit signed integer to this instance.

Append(Int32) Append(Int32) Append(Int32) Append(Int32)

將指定的 32 位元帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 32-bit signed integer to this instance.

Append(Int64) Append(Int64) Append(Int64) Append(Int64)

將指定的 64 位元帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 64-bit signed integer to this instance.

Append(Object) Append(Object) Append(Object) Append(Object)

將指定物件的字串表示附加至這個執行個體。Appends the string representation of a specified object to this instance.

Append(Double) Append(Double) Append(Double) Append(Double)

將指定的雙精度浮點數之字串表示附加至這個執行個體。Appends the string representation of a specified double-precision floating-point number to this instance.

Append(StringBuilder) Append(StringBuilder) Append(StringBuilder) Append(StringBuilder)

將指定字串產生器的字串表示附加至這個執行個體。Appends the string representation of a specified string builder to this instance.

public:
 System::Text::StringBuilder ^ Append(System::Text::StringBuilder ^ value);
public System.Text.StringBuilder Append (System.Text.StringBuilder value);
member this.Append : System.Text.StringBuilder -> System.Text.StringBuilder
Public Function Append (value As StringBuilder) As StringBuilder

參數

value
StringBuilder StringBuilder StringBuilder StringBuilder

要附加的字串產生器。The string builder to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation is completed.

Append(UInt16) Append(UInt16) Append(UInt16) Append(UInt16)

重要

此 API 不符合 CLS 規範。

將指定的 16 位元不帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 16-bit unsigned integer to this instance.

public:
 System::Text::StringBuilder ^ Append(System::UInt16 value);
[System.CLSCompliant(false)]
public System.Text.StringBuilder Append (ushort value);
member this.Append : uint16 -> System.Text.StringBuilder
Public Function Append (value As UShort) As StringBuilder

參數

value
UInt16 UInt16 UInt16 UInt16

要附加的值。The value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(UInt16)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(UInt16) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

System.Text.StringBuilder sb = new 
            System.Text.StringBuilder("The range of a 16-bit unsigned integer: ");
sb.Append(UInt16.MinValue).Append(" to ").Append(UInt16.MaxValue);
Console.WriteLine(sb);
// The example displays the following output:
//       The range of a 16-bit unsigned integer: 0 to 65535
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)
' The example displays the following output:
'       The range of a 16-bit unsigned integer: 0 to 65535

方法會呼叫方法,以value取得的字串表示。 UInt16.ToString(IFormatProvider) Append(UInt16)The Append(UInt16) method calls the UInt16.ToString(IFormatProvider) method to get the string representation of value. 若要控制的格式value,請AppendFormat呼叫方法。To control the formatting of value, call the AppendFormat method.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(UInt32) Append(UInt32) Append(UInt32) Append(UInt32)

重要

此 API 不符合 CLS 規範。

將指定的 32 位元不帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 32-bit unsigned integer to this instance.

public:
 System::Text::StringBuilder ^ Append(System::UInt32 value);
[System.CLSCompliant(false)]
public System.Text.StringBuilder Append (uint value);
member this.Append : uint32 -> System.Text.StringBuilder
Public Function Append (value As UInteger) As StringBuilder

參數

value
UInt32 UInt32 UInt32 UInt32

要附加的值。The value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(UInt32)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(UInt32) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

System.Text.StringBuilder sb = new 
            System.Text.StringBuilder("The range of a 32-bit unsigned integer: ");
sb.Append(UInt32.MinValue).Append(" to ").Append(UInt32.MaxValue);
Console.WriteLine(sb);
// The example displays the following output:
//       The range of a 32-bit unsigned integer: 0 to 4294967295
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)
' The example displays the following output:
'       The range of a 32-bit unsigned integer: 0 to 4294967295

Append(UInt32) value呼叫方法,以取得目前文化特性的字串表示。 UInt32.ToStringThe Append(UInt32) calls the UInt32.ToString method to get the string representation of value for the current culture. 若要控制的格式value,請AppendFormat呼叫方法。To control the formatting of value, call the AppendFormat method.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(UInt64) Append(UInt64) Append(UInt64) Append(UInt64)

重要

此 API 不符合 CLS 規範。

將指定的 64 位元不帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 64-bit unsigned integer to this instance.

public:
 System::Text::StringBuilder ^ Append(System::UInt64 value);
[System.CLSCompliant(false)]
public System.Text.StringBuilder Append (ulong value);
member this.Append : uint64 -> System.Text.StringBuilder
Public Function Append (value As ULong) As StringBuilder

參數

value
UInt64 UInt64 UInt64 UInt64

要附加的值。The value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(UInt64)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(UInt64) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

System.Text.StringBuilder sb = new 
            System.Text.StringBuilder("The range of a 64-bit unsigned integer: ");
sb.Append(UInt64.MinValue).Append(" to ").Append(UInt64.MaxValue);
Console.WriteLine(sb);
// The example displays the following output:
//       The range of a 64-bit unsigned integer: 0 to 18446744073709551615
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)
' The example displays the following output:
'       The range of a 64-bit unsigned integer: 0 to 18446744073709551615

方法會呼叫方法,以value取得目前文化特性的字串表示。 UInt64.ToString(IFormatProvider) Append(UInt64)The Append(UInt64) method calls the UInt64.ToString(IFormatProvider) method to get the string representation of value for the current culture. 若要控制的格式value,請AppendFormat呼叫方法。To control the formatting of value, call the AppendFormat method.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(Char[], Int32, Int32) Append(Char[], Int32, Int32) Append(Char[], Int32, Int32) Append(Char[], Int32, Int32)

將 Unicode 字元之指定子陣列的字串表示附加至這個執行個體。Appends the string representation of a specified subarray of Unicode characters to this instance.

public:
 System::Text::StringBuilder ^ Append(cli::array <char> ^ value, int startIndex, int charCount);
public System.Text.StringBuilder Append (char[] value, int startIndex, int charCount);
member this.Append : char[] * int * int -> System.Text.StringBuilder
Public Function Append (value As Char(), startIndex As Integer, charCount As Integer) As StringBuilder

參數

value
Char[]

字元陣列。A character array.

startIndex
Int32 Int32 Int32 Int32

value 中的開始位置。The starting position in value.

charCount
Int32 Int32 Int32 Int32

要附加的字元數。The number of characters to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

valuenull,而 startIndexcharCount 不是零。value is null, and startIndex and charCount are not zero.

charCount 小於零。charCount is less than zero.

-或--or- startIndex 小於零。startIndex is less than zero.

-或--or- startIndex + charCount 大於 value 的長度。startIndex + charCount is greater than the length of value.

-或--or- 加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

這個方法會將指定範圍的字元value附加至目前的實例。This method appends the specified range of characters in value to the current instance. 如果valuenull,且和count都是零,則不會進行任何變更。 startIndexIf value is null and startIndex and count are both zero, no changes are made.

Append(Char[], Int32, Int32)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Char[], Int32, Int32) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

char[] chars = { 'a', 'b', 'c', 'd', 'e'};
System.Text.StringBuilder sb = new System.Text.StringBuilder();
int startPosition = Array.IndexOf(chars, 'a');
int endPosition = Array.IndexOf(chars, 'c');
if (startPosition >= 0 && endPosition >= 0) {
   sb.Append("The array from positions ").Append(startPosition).
             Append(" to ").Append(endPosition).Append(" contains ").
             Append(chars, startPosition, endPosition + 1).Append(".");
   Console.WriteLine(sb);
}             
// The example displays the following output:
//       The array from positions 0 to 2 contains abc.
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             
' The example displays the following output:
'       The array from positions 0 to 2 contains abc.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(Char*, Int32) Append(Char*, Int32) Append(Char*, Int32)

重要

此 API 不符合 CLS 規範。

符合 CLS 規範替代方案
System.Text.StringBuilder.Append(Char[], Int32, Int32)

將指定位址開頭的 Unicode 字元陣列附加至這個執行個體。Appends an array of Unicode characters starting at a specified address to this instance.

public:
 System::Text::StringBuilder ^ Append(char* value, int valueCount);
[System.CLSCompliant(false)]
[System.Security.SecurityCritical]
public System.Text.StringBuilder Append (char* value, int valueCount);
member this.Append : nativeptr<char> * int -> System.Text.StringBuilder

參數

value
Char*

字元陣列的指標。A pointer to an array of characters.

valueCount
Int32 Int32 Int32 Int32

陣列中的字元數。The number of characters in the array.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

valueCount 小於零。valueCount is less than zero.

-或--or- 加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

這個方法會valueCount將從位址value開始的字元附加至目前的實例。This method appends valueCount characters starting at address value to the current instance.

Append(Char*, Int32)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Char*, Int32) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

Append(String) Append(String) Append(String) Append(String)

將指定字串的複本附加至這個執行個體。Appends a copy of the specified string to this instance.

public:
 System::Text::StringBuilder ^ Append(System::String ^ value);
public System.Text.StringBuilder Append (string value);
member this.Append : string -> System.Text.StringBuilder
Public Function Append (value As String) As StringBuilder

參數

value
String String String String

要附加的字串。The string to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(String)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(String) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

bool flag = false;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("The value of the flag is ").Append(flag).Append(".");
Console.WriteLine(sb.ToString());
// The example displays the following output:
//       The value of the flag is False.
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())
' The example displays the following output:
'       The value of the flag is False.

如果valuenull,則不會進行任何變更。If value is null, no changes are made.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(String, Int32, Int32) Append(String, Int32, Int32) Append(String, Int32, Int32) Append(String, Int32, Int32)

將指定子字串的複本附加至這個執行個體。Appends a copy of a specified substring to this instance.

public:
 System::Text::StringBuilder ^ Append(System::String ^ value, int startIndex, int count);
public System.Text.StringBuilder Append (string value, int startIndex, int count);
member this.Append : string * int * int -> System.Text.StringBuilder
Public Function Append (value As String, startIndex As Integer, count As Integer) As StringBuilder

參數

value
String String String String

包含要附加之子字串的字串。The string that contains the substring to append.

startIndex
Int32 Int32 Int32 Int32

value 中子字串的開始位置。The starting position of the substring within value.

count
Int32 Int32 Int32 Int32

value 中要附加的字元數。The number of characters in value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

valuenull,而 startIndexcount 不是零。value is null, and startIndex and count are not zero.

count 小於零。count less than zero.

-或--or- startIndex 小於零。startIndex less than zero.

-或--or- startIndex + count 大於 value 的長度。startIndex + count is greater than the length of value.

-或--or- 加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

這個方法會將指定範圍的字元value附加至目前的實例。This method appends the specified range of characters in value to the current instance. 如果valuenull,且和count都是零,則不會進行任何變更。 startIndexIf value is null and startIndex and count are both zero, no changes are made.

Append(String, Int32, Int32)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(String, Int32, Int32) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

string str = "First;George Washington;1789;1797";
int index = 0;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
int length = str.IndexOf(';', index);      
sb.Append(str, index, length).Append(" President of the United States: ");
index += length + 1;
length = str.IndexOf(';', index) - index;
sb.Append(str, index, length).Append(", from ");
index += length + 1;
length = str.IndexOf(';', index) - index;
sb.Append(str, index, length).Append(" to ");
index += length + 1;
sb.Append(str, index, str.Length - index);
Console.WriteLine(sb);
// The example displays the following output:
//    First President of the United States: George Washington, from 1789 to 1797      
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)
' The example displays the following output:
'    First President of the United States: George Washington, from 1789 to 1797      

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(StringBuilder, Int32, Int32) Append(StringBuilder, Int32, Int32) Append(StringBuilder, Int32, Int32) Append(StringBuilder, Int32, Int32)

將所指定字串產生器內的子字串複本附加至這個執行個體。Appends a copy of a substring within a specified string builder to this instance.

public:
 System::Text::StringBuilder ^ Append(System::Text::StringBuilder ^ value, int startIndex, int count);
public System.Text.StringBuilder Append (System.Text.StringBuilder value, int startIndex, int count);
member this.Append : System.Text.StringBuilder * int * int -> System.Text.StringBuilder
Public Function Append (value As StringBuilder, startIndex As Integer, count As Integer) As StringBuilder

參數

value
StringBuilder StringBuilder StringBuilder StringBuilder

字串產生器,其中包含要附加的子字串。The string builder that contains the substring to append.

startIndex
Int32 Int32 Int32 Int32

value 中子字串的開始位置。The starting position of the substring within value.

count
Int32 Int32 Int32 Int32

value 中要附加的字元數。The number of characters in value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

Append(Char, Int32) Append(Char, Int32) Append(Char, Int32) Append(Char, Int32)

將 Unicode 字元其字串表示的指定複本數附加至這個執行個體。Appends a specified number of copies of the string representation of a Unicode character to this instance.

public:
 System::Text::StringBuilder ^ Append(char value, int repeatCount);
public System.Text.StringBuilder Append (char value, int repeatCount);
member this.Append : char * int -> System.Text.StringBuilder
Public Function Append (value As Char, repeatCount As Integer) As StringBuilder

參數

value
Char Char Char Char

要附加的字元。The character to append.

repeatCount
Int32 Int32 Int32 Int32

要附加 value 的次數。The number of times to append value.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

repeatCount 小於零。repeatCount is less than zero.

-或--or- 加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(Char, Int32)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Char, Int32) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

decimal value = 1346.19m;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append('*', 5).AppendFormat("{0:C2}", value).Append('*', 5);
Console.WriteLine(sb);
// The example displays the following output:
//       *****$1,346.19*****
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)
' The example displays the following output:
'       *****$1,346.19*****

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(SByte) Append(SByte) Append(SByte) Append(SByte)

重要

此 API 不符合 CLS 規範。

將指定的 8 位元帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 8-bit signed integer to this instance.

public:
 System::Text::StringBuilder ^ Append(System::SByte value);
[System.CLSCompliant(false)]
public System.Text.StringBuilder Append (sbyte value);
member this.Append : sbyte -> System.Text.StringBuilder
Public Function Append (value As SByte) As StringBuilder

參數

value
SByte SByte SByte SByte

要附加的值。The value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(SByte)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(SByte) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

System.Text.StringBuilder sb = new 
            System.Text.StringBuilder("The range of an 8-bit signed integer: ");
sb.Append(SByte.MinValue).Append(" to ").Append(SByte.MaxValue);
Console.WriteLine(sb);
// The example displays the following output:
//       The range of an 8-bit unsigned integer: -128 to 127 
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)
' The example displays the following output:
'       The range of an 8-bit unsigned integer: -128 to 127 

方法會呼叫方法,以value取得目前文化特性的字串表示。 SByte.ToString(IFormatProvider) Append(SByte)The Append(SByte) method calls the SByte.ToString(IFormatProvider) method to get the string representation of value for the current culture. 若要控制的格式value,請AppendFormat呼叫方法。To control the formatting of value, call the AppendFormat method.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(Single) Append(Single) Append(Single) Append(Single)

將指定的單精確度浮點數之字串表示附加至這個執行個體。Appends the string representation of a specified single-precision floating-point number to this instance.

public:
 System::Text::StringBuilder ^ Append(float value);
public System.Text.StringBuilder Append (float value);
member this.Append : single -> System.Text.StringBuilder
Public Function Append (value As Single) As StringBuilder

參數

value
Single Single Single Single

要附加的值。The value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(Single)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Single) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

float value = 1034769.47f;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append('*', 5).Append(value).Append('*', 5);
Console.WriteLine(sb);
// The example displays the following output:
//       *****1034769.47*****
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)
' The example displays the following output:
'       *****1034769.47*****

方法會呼叫方法,以value取得目前文化特性的字串表示。 Single.ToString Append(Single)The Append(Single) method calls the Single.ToString method to get the string representation of value for the current culture. 若要控制的格式value,請AppendFormat呼叫方法。To control the formatting of value, call the AppendFormat method.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(ReadOnlyMemory<Char>) Append(ReadOnlyMemory<Char>) Append(ReadOnlyMemory<Char>) Append(ReadOnlyMemory<Char>)

將所指定唯讀字元記憶體區域的字串表示附加至這個執行個體。Appends the string representation of a specified read-only character memory region to this instance.

public:
 System::Text::StringBuilder ^ Append(ReadOnlyMemory<char> value);
public System.Text.StringBuilder Append (ReadOnlyMemory<char> value);
member this.Append : ReadOnlyMemory<char> -> System.Text.StringBuilder
Public Function Append (value As ReadOnlyMemory(Of Char)) As StringBuilder

參數

value
ReadOnlyMemory<Char>

要附加的唯讀字元記憶體區域。The read-only character memory region to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation is completed.

Append(Boolean) Append(Boolean) Append(Boolean) Append(Boolean)

將指定的布林 (Boolean) 值之字串表示附加至這個執行個體。Appends the string representation of a specified Boolean value to this instance.

public:
 System::Text::StringBuilder ^ Append(bool value);
public System.Text.StringBuilder Append (bool value);
member this.Append : bool -> System.Text.StringBuilder
Public Function Append (value As Boolean) As StringBuilder

參數

value
Boolean Boolean Boolean Boolean

要附加的布林值。The Boolean value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(Boolean)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Boolean) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

bool flag = false;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("The value of the flag is ").Append(flag).Append(".");
Console.WriteLine(sb.ToString());
// The example displays the following output:
//       The value of the flag is False.
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())
' The example displays the following output:
'       The value of the flag is False.

方法會呼叫方法,以value取得的字串表示。 Boolean.ToString() Append(Boolean)The Append(Boolean) method calls the Boolean.ToString() method to get the string representation of value. 這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(ReadOnlySpan<Char>) Append(ReadOnlySpan<Char>) Append(ReadOnlySpan<Char>) Append(ReadOnlySpan<Char>)

將所指定唯讀字元範圍的字串表示附加至這個執行個體。Appends the string representation of a specified read-only character span to this instance.

public:
 System::Text::StringBuilder ^ Append(ReadOnlySpan<char> value);
public System.Text.StringBuilder Append (ReadOnlySpan<char> value);
member this.Append : ReadOnlySpan<char> -> System.Text.StringBuilder
Public Function Append (value As ReadOnlySpan(Of Char)) As StringBuilder

參數

value
ReadOnlySpan<Char>

要附加的唯讀字元範圍。The read-only character span to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation is completed.

Append(Char) Append(Char) Append(Char) Append(Char)

將指定 Char 物件的字串表示附加至這個執行個體。Appends the string representation of a specified Char object to this instance.

public:
 System::Text::StringBuilder ^ Append(char value);
public System.Text.StringBuilder Append (char value);
member this.Append : char -> System.Text.StringBuilder
Public Function Append (value As Char) As StringBuilder

參數

value
Char Char Char Char

要附加的 UTF-16 編碼字碼單位。The UTF-16-encoded code unit to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(Char)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Char) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

string str = "Characters in a string.";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
foreach (var ch in str)
   sb.Append(" '").Append(ch).Append("' ");

Console.WriteLine("Characters in the string:");
Console.WriteLine("  {0}", sb);
// The example displays the following output:
//    Characters in the string:
//       'C'  'h'  'a'  'r'  'a'  'c'  't'  'e'  'r'  's'  ' '  'i'  'n'  ' '  'a'  ' '  's'  't' 'r'  'i'  'n'  'g'  '.'      
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)
' The example displays the following output:
'    Characters in the string:
'       'C'  'h'  'a'  'r'  'a'  'c'  't'  'e'  'r'  's'  ' '  'i'  'n'  ' '  'a'  ' '  's'  't' 'r'  'i'  'n'  'g'  '.'      

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(Char[]) Append(Char[]) Append(Char[]) Append(Char[])

將指定陣列中的 Unicode 字元的字串表示附加至這個執行個體。Appends the string representation of the Unicode characters in a specified array to this instance.

public:
 System::Text::StringBuilder ^ Append(cli::array <char> ^ value);
public System.Text.StringBuilder Append (char[] value);
member this.Append : char[] -> System.Text.StringBuilder
Public Function Append (value As Char()) As StringBuilder

參數

value
Char[]

要附加的字元陣列。The array of characters to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

這個方法會將指定陣列中的所有字元附加至目前的實例,其順序會與它們在value中的相同。This method appends all the characters in the specified array to the current instance in the same order as they appear in value. 如果valuenull,則不會進行任何變更。If value is null, no changes are made.

Append(Char[])方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Char[]) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

char[] chars = { 'a', 'e', 'i', 'o', 'u' };
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("The characters in the array: ").Append(chars);
Console.WriteLine(sb);
// The example displays the following output:
//      The characters in the array: aeiou
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)
' The example displays the following output:
'      The characters in the array: aeiou

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

Append(Decimal) Append(Decimal) Append(Decimal) Append(Decimal)

將指定的小數位數之字串表示附加至這個執行個體。Appends the string representation of a specified decimal number to this instance.

public:
 System::Text::StringBuilder ^ Append(System::Decimal value);
public System.Text.StringBuilder Append (decimal value);
member this.Append : decimal -> System.Text.StringBuilder
Public Function Append (value As Decimal) As StringBuilder

參數

value
Decimal Decimal Decimal Decimal

要附加的值。The value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(Decimal)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Decimal) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

decimal value = 1346.19m;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append('*', 5).Append(value).Append('*', 5);
Console.WriteLine(sb);
// The example displays the following output:
//       *****1346.19*****
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)
' The example displays the following output:
'       *****1346.19*****

方法會呼叫方法,以value取得目前文化特性的字串表示。 Decimal.ToString(IFormatProvider) Append(Decimal)The Append(Decimal) method calls the Decimal.ToString(IFormatProvider) method to get the string representation of value for the current culture. 若要控制的格式value,請AppendFormat呼叫方法。To control the formatting of value, call the AppendFormat method.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(Byte) Append(Byte) Append(Byte) Append(Byte)

將指定的 8 位元不帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 8-bit unsigned integer to this instance.

public:
 System::Text::StringBuilder ^ Append(System::Byte value);
public System.Text.StringBuilder Append (byte value);
member this.Append : byte -> System.Text.StringBuilder
Public Function Append (value As Byte) As StringBuilder

參數

value
Byte Byte Byte Byte

要附加的值。The value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(Byte)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Byte) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

Byte[] bytes = { 16, 132, 27, 253 };
System.Text.StringBuilder sb = new System.Text.StringBuilder();
foreach (var value in bytes)
   sb.Append(value).Append(" ");         

Console.WriteLine("The byte array: {0}", sb.ToString());
// The example displays the following output:
//         The byte array: 16 132 27 253      
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())
' The example displays the following output:
'         The byte array: 16 132 27 253      

方法會呼叫方法,以value取得目前文化特性的字串表示。 ToString(IFormatProvider) Append(Byte)The Append(Byte) method calls the ToString(IFormatProvider) method to get the string representation of value for the current culture. 若要控制的格式value,請AppendFormat呼叫方法。To control the formatting of value, call the AppendFormat method.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(Int16) Append(Int16) Append(Int16) Append(Int16)

將指定的 16 位元帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 16-bit signed integer to this instance.

public:
 System::Text::StringBuilder ^ Append(short value);
public System.Text.StringBuilder Append (short value);
member this.Append : int16 -> System.Text.StringBuilder
Public Function Append (value As Short) As StringBuilder

參數

value
Int16 Int16 Int16 Int16

要附加的值。The value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(Int16)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Int16) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

System.Text.StringBuilder sb = new 
       System.Text.StringBuilder("The range of a 16-bit integer: ");
sb.Append(Int16.MinValue).Append(" to ").Append(Int16.MaxValue);
Console.WriteLine(sb);
// The example displays the following output:
//       The range of a 16-bit integer: -32768 to 32767
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)
' The example displays the following output:
'       The range of a 16-bit integer: -32768 to 32767

方法會呼叫方法,以value取得目前文化特性的字串表示。 Int16.ToString(IFormatProvider) Append(Int16)The Append(Int16) method calls the Int16.ToString(IFormatProvider) method to get the string representation of value for the current culture. 若要控制的格式value,請AppendFormat呼叫方法。To control the formatting of value, call the AppendFormat method.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(Int32) Append(Int32) Append(Int32) Append(Int32)

將指定的 32 位元帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 32-bit signed integer to this instance.

public:
 System::Text::StringBuilder ^ Append(int value);
public System.Text.StringBuilder Append (int value);
member this.Append : int -> System.Text.StringBuilder
Public Function Append (value As Integer) As StringBuilder

參數

value
Int32 Int32 Int32 Int32

要附加的值。The value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(Int32)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Int32) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

System.Text.StringBuilder sb = new 
       System.Text.StringBuilder("The range of a 32-bit integer: ");
sb.Append(Int32.MinValue).Append(" to ").Append(Int32.MaxValue);
Console.WriteLine(sb);
// The example displays the following output:
//       The range of a 32-bit integer: -2147483648 to 2147483647
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)
' The example displays the following output:
'       The range of a 32-bit integer: -2147483648 to 2147483647

方法會呼叫方法,以value取得目前文化特性的字串表示。 Int32.ToString(IFormatProvider) Append(Int32)The Append(Int32) method calls the Int32.ToString(IFormatProvider) method to get the string representation of value for the current culture. 若要控制的格式value,請AppendFormat呼叫方法。To control the formatting of value, call the AppendFormat method.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(Int64) Append(Int64) Append(Int64) Append(Int64)

將指定的 64 位元帶正負號的整數之字串表示附加至這個執行個體。Appends the string representation of a specified 64-bit signed integer to this instance.

public:
 System::Text::StringBuilder ^ Append(long value);
public System.Text.StringBuilder Append (long value);
member this.Append : int64 -> System.Text.StringBuilder
Public Function Append (value As Long) As StringBuilder

參數

value
Int64 Int64 Int64 Int64

要附加的值。The value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(Int64)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Int64) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

System.Text.StringBuilder sb = new 
            System.Text.StringBuilder("The range of a 64-bit integer: ");
sb.Append(Int64.MinValue).Append(" to ").Append(Int64.MaxValue);
Console.WriteLine(sb);
// The example displays the following output:
//       The range of a 64-bit integer:  -9223372036854775808 to 9223372036854775807
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)
' The example displays the following output:
'       The range of a 64-bit integer:  -9223372036854775808 to 9223372036854775807

方法會呼叫,以取得目前文化特性的value字串表示。 Int64.ToString(IFormatProvider) Append(Int64)The Append(Int64) method calls the Int64.ToString(IFormatProvider) to get the string representation of value for the current culture. 若要控制的格式value,請AppendFormat呼叫方法。To control the formatting of value, call the AppendFormat method.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(Object) Append(Object) Append(Object) Append(Object)

將指定物件的字串表示附加至這個執行個體。Appends the string representation of a specified object to this instance.

public:
 System::Text::StringBuilder ^ Append(System::Object ^ value);
public System.Text.StringBuilder Append (object value);
member this.Append : obj -> System.Text.StringBuilder
Public Function Append (value As Object) As StringBuilder

參數

value
Object Object Object Object

要附加的物件。The object to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(Object)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Object) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates. 它會定義Dog類別、 Dog建立物件,並對Append方法進行三個呼叫,以建立包含狗名稱和知名的字串。It defines a Dog class, creates a Dog object, and makes three calls to the Append method to create a string that contains the dog's name and breed.

using System;

public class Dog
{
   private string dogBreed;
   private string dogName;
   
   public Dog(string name, string breed)
   {
      this.dogName = name;
      this.dogBreed = breed;
   }
   
   public string Breed {
      get { return this.dogBreed; }
   }
   
   public string Name {
      get { return this.dogName; }
   }
   
   public override string ToString()
   {
      return this.dogName;
   }
}

public class Example
{
   public static void Main()
   {
      Dog dog1 = new Dog("Yiska", "Alaskan Malamute");
      System.Text.StringBuilder sb = new System.Text.StringBuilder();     
      sb.Append(dog1).Append(", Breed: ").Append(dog1.Breed);  
      Console.WriteLine(sb);
   }
}
// The example displays the following output:
//        Yiska, Breed: Alaskan Malamute
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
' The example displays the following output:
'       Yiska, Breed: Alaskan Malamute

方法會呼叫方法,以value取得的字串表示。 Object.ToString Append(Object)The Append(Object) method calls the Object.ToString method to get the string representation of value. 如果value StringBuildernull,則不會對物件進行任何變更。If value is null, no changes are made to the StringBuilder object.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

Append(Double) Append(Double) Append(Double) Append(Double)

將指定的雙精度浮點數之字串表示附加至這個執行個體。Appends the string representation of a specified double-precision floating-point number to this instance.

public:
 System::Text::StringBuilder ^ Append(double value);
public System.Text.StringBuilder Append (double value);
member this.Append : double -> System.Text.StringBuilder
Public Function Append (value As Double) As StringBuilder

參數

value
Double Double Double Double

要附加的值。The value to append.

傳回

完成附加作業之後,這個執行個體的參考。A reference to this instance after the append operation has completed.

例外狀況

加大此執行個體的值可能會超過 MaxCapacityEnlarging the value of this instance would exceed MaxCapacity.

備註

Append(Double)方法會修改這個類別的現有實例,而不會傳回新的類別實例。The Append(Double) method modifies the existing instance of this class; it does not return a new class instance. 因此,您可以在現有的參考上呼叫方法或屬性,而不需要將傳回值指派給StringBuilder物件,如下列範例所示。Because of this, you can call a method or property on the existing reference and you do not have to assign the return value to a StringBuilder object, as the following example illustrates.

double value = 1034769.47;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append('*', 5).Append(value).Append('*', 5);
Console.WriteLine(sb);
// The example displays the following output:
//       *****1034769.47*****
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)
' The example displays the following output:
'       *****1034769.47*****

方法會呼叫方法,以value取得目前文化特性的字串表示。 Double.ToString(IFormatProvider) Append(Double)The Append(Double) method calls the Double.ToString(IFormatProvider) method to get the string representation of value for the current culture. 若要控制的格式value,請AppendFormat呼叫方法。To control the formatting of value, call the AppendFormat method.

這個實例的容量會視需要調整。The capacity of this instance is adjusted as needed.

給呼叫者的注意事項

在 .net Core 和 .NET Framework 4.0 和更新版本中,當您藉由呼叫StringBuilderStringBuilder(Int32, Int32)函式來具現化物件時, StringBuilder實例的長度和容量都可以成長超過其MaxCapacity的值property.In .NET Core and in the .NET Framework 4.0 and later versions, when you instantiate the StringBuilder object by calling the StringBuilder(Int32, Int32) constructor, both the length and the capacity of the StringBuilder instance can grow beyond the value of its MaxCapacity property. 當您呼叫Append(String)AppendFormat(String, Object)方法來附加小型字串時,可能會發生這種情況。This can occur particularly when you call the Append(String) and AppendFormat(String, Object) methods to append small strings.

另請參閱

適用於