BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.Object System.Runtime.Serialization.ISerializable System.Runtime.InteropServices.ComVisible(true)

This class represents a string-like object whose value is a mutable sequence of characters.

In this section:

The String and StringBuilder types

How StringBuilder works

Memory allocation

Instantiating a StringBuilder object

Calling StringBuilder methods

Performing StringBuilder operations

Iterating StringBuilder characters

Adding text to a StringBuilder object

Deleting text from a StringBuilder object

Modifying the text in a StringBuilder object

Searching the text in a StringBuilder object

Converting the StringBuilder object to a string

## The String and StringBuilder types

Although and both represent sequences of characters, they are implemented differently. is an immutable type. That is, each operation that appears to modify a object actually creates a new string.

For example, the call to the method in the following C# example appears to change the value of a string variable named value. In fact, the method returns a value object that has a different value and address from the value object that was passed to the method. Note that the example must be compiled using the /unsafe compiler option.

code reference: System.Text.StringBuilder.Class#1

For routines that perform extensive string manipulation (such as apps that modify a string numerous times in a loop), modifying a string repeatedly can exact a significant performance penalty. The alternative is to use , which is a mutable string class. Mutability means that once an instance of the class has been created, it can be modified by appending, removing, replacing, or inserting characters. A object maintains a buffer to accommodate expansions to the string. New data is appended to the buffer if room is available; otherwise, a new, larger buffer is allocated, data from the original buffer is copied to the new buffer, and the new data is then appended to the new buffer.

Although the class generally offers better performance than the class, you should not automatically replace with whenever you want to manipulate strings. Performance depends on the size of the string, the amount of memory to be allocated for the new string, the system on which your app is executing, and the type of operation. You should be prepared to test your app to determine whether actually offers a significant performance improvement.

Consider using the class under these conditions:

When the number of changes that your app will make to a string is small. In these cases, might offer negligible or no performance improvement over .

When you are performing a fixed number of concatenation operations, particularly with string literals. In this case, the compiler might combine the concatenation operations into a single operation.

When you have to perform extensive search operations while you are building your string. The class lacks search methods such as IndexOf or StartsWith. You'll have to convert the object to a for these operations, and this can negate the performance benefit from using . For more information, see the Searching the text in a StringBuilder object section.

Consider using the class under these conditions:

When you expect your app to make an unknown number of changes to a string at design time (for example, when you are using a loop to concatenate a random number of strings that contain user input).

When you expect your app to make a significant number of changes to a string.

## How StringBuilder works

The property indicates the number of characters the object currently contains. If you add characters to the object, its length increases until it equals the size of the property, which defines the number of characters that the object can contain. If the number of added characters causes the length of the object to exceed its current capacity, new memory is allocated, the value of the property is doubled, new characters are added to the object, and its property is adjusted. Additional memory for the object is allocated dynamically until it reaches the value defined by the property. When the maximum capacity is reached, no further memory can be allocated for the object, and trying to add characters or expand it beyond its maximum capacity throws either an or an exception.

The following example illustrates how a object allocates new memory and increases its capacity dynamically as the string assigned to the object expands. The code creates a object by calling its default (parameterless) constructor. The default capacity of this object is 16 characters, and its maximum capacity is more than 2 billion characters. Appending the string "This is a sentence." results in a new memory allocation because the string length (19 characters) exceeds the default capacity of the object. The capacity of the object doubles to 32 characters, the new string is added, and the length of the object now equals 19 characters. The code then appends the string "This is an additional sentence." to the value of the object 11 times. Whenever the append operation causes the length of the object to exceed its capacity, its existing capacity is doubled and the operation succeeds.

code reference: System.Text.StringBuilder.Class#3

## Memory allocation

The default capacity of a object is 16 characters, and its default maximum capacity is . These default values are used if you call the and constructors.

You can explicitly define the initial capacity of a object in the following ways:

By calling any of the constructors that includes a parameter when you create the object.

By explicitly assigning a new value to the property to expand an existing object. Note that the property throws an exception if the new capacity is less than the existing capacity or greater than the object's maximum capacity.

By calling the method with the new capacity. The new capacity must not be greater than the object's maximum capacity. However, unlike an assignment to the property, does not throw an exception if the desired new capacity is less than the existing capacity; in this case, the method call has no effect.

If the length of the string assigned to the object in the constructor call exceeds either the default capacity or the specified capacity, the property is set to the length of the string specified with the parameter.

You can explicitly define the maximum capacity of a object by calling the constructor. You can't change the maximum capacity by assigning a new value to the property, because it is read-only.

As the previous section shows, whenever the existing capacity is inadequate, additional memory is allocated and the capacity of a object doubles up to the value defined by the property.

In general, the default capacity and maximum capacity are adequate for most apps. You might consider setting these values under the following conditions:

If the eventual size of the object is likely to grow exceedingly large, typically in excess of several megabytes. In this case, there may be some performance benefit from setting the initial property to a significantly high value to eliminate the need for too many memory reallocations.

If your app is running on a system with limited memory. In this case, you may want to consider setting the property to less than if your app is handling large strings that may cause it to execute in a memory-constrained environment.

## Instantiating a StringBuilder object

You instantiate a object by calling one of its six overloaded class constructors, which are listed in the following table. Three of the constructors instantiate a object whose value is an empty string, but set its and values differently. The remaining three constructors define a object that has a specific string value and capacity. Two of the three constructors use the default maximum capacity of , whereas the third allows you to set the maximum capacity.

Constructor

String value

Capacity

Maximum capacity

16

Defined by the parameter

Defined by the parameter

Defined by the parameter

Defined by the parameter

16 or . , whichever is greater

Defined by the parameter

Defined by the parameter or . , whichever is greater.

Defined by . (, )

Defined by the parameter or . , whichever is greater.

Defined by the parameter

The following example uses three of these constructor overloads to instantiate objects.

code reference: System.Text.StringBuilder.Class#6

## Calling StringBuilder methods

Most of the methods that modify the string in a instance return a reference to that same instance. This enables you to call methods in two ways:

You can make individual method calls and ignore the return value, as the following example does.

code reference: System.Text.StringBuilder.Class#4

You can make a series of method calls in a single statement. This can be convenient if you want to write a single statement that chains successive operations. The following example consolidates three method calls from the previous example into a single line of code.

code reference: System.Text.StringBuilder.Class#5

## Performing StringBuilder operations

You can use the methods of the class to iterate, add, delete, or modify characters in a object.

## Iterating StringBuilder characters

You can access the characters in a object by using the property. In C#, is an indexer; in Visual Basic, it is the default property of the class. This enables you to set or retrieve individual characters by using their index only, without explicitly referencing the property. Characters in a object begin at index 0 (zero) and continue to index - 1.

The following example illustrates the property. It appends ten random numbers to a object, and then iterates each character. If the character's Unicode category is , it decreases the number by 1 (or changes the number to 9 if its value is 0). The example displays the contents of the object both before and after the values of individual characters were changed.

code reference: System.Text.StringBuilder.Class#7

## Adding text to a StringBuilder object

The class includes the following methods for expanding the contents of a object:

The method appends a string, a substring, a character array, a portion of a character array, a single character repeated multiple times, or the string representation of a primitive data type to a object.

The method appends a line terminator or a string along with a line terminator to a object.

The method appends a composite format string to a object. The string representations of objects included in the result string can reflect the formatting conventions of the current system culture or a specified culture.

The method inserts a string, a substring, multiple repetitions of a string, a character array, a portion of a character array, or the string representation of a primitive data type at a specified position in the object. The position is defined by a zero-based index.

The following example uses the , , , and methods to expand the text of a object.

code reference: System.Text.StringBuilder.Class#9

## Deleting text from a StringBuilder object

The class includes methods that can reduce the size of the current instance. The method removes all characters and sets the property to zero. The method deletes a specified number of characters starting at a particular index position. In addition, you can remove characters from the end of a object by setting its property to a value that is less than the length of the current instance.

The following example removes some of the text from a object, displays its resulting capacity, maximum capacity, and length property values, and then calls the method to remove all the characters from the object.

code reference: System.Text.StringBuilder.Class#10

## Modifying the text in a StringBuilder object

The method replaces all occurrences of a character or a string in the entire object or in a particular character range. The following example uses the method to replace all exclamation points (!) with question marks (?) in the object.

code reference: System.Text.StringBuilder.Class#11

## Searching the text in a StringBuilder object

The class does not include methods similar to the , , and methods provided by the class, which allow you to search the object for a particular character or a substring. Determining the presence or starting character position of a substring requires that you search a value by using either a string search method or a regular expression method. There are four ways to implement such searches, as the following table shows.

Technique

Pros

Cons

Search string values before adding them to the object.

Useful for determining whether a substring exists.

Cannot be used when the index position of a substring is important.

Call and search the returned object.

Easy to use if you assign all the text to a object, and then begin to modify it.

Cumbersome to repeatedly call if you must make modifications before all text is added to the object.

You must remember to work from the end of the object's text if you're making changes.

Use the property to sequentially search a range of characters.

Useful if you're concerned with individual characters or a small substring.

Cumbersome if the number of characters to search is large or if the search logic is complex.

Convert the object to a object, and perform modifications on the object.

Useful if the number of modifications is small.

Negates the performance benefit of the class if the number of modifications is large.

Let's examine these techniques in greater detail.

If the goal of the search is to determine whether a particular substring exists (that is, if you aren't interested in the position of the substring), you can search strings before storing them in the object. The following example provides one possible implementation. It defines a StringBuilderFinder class whose constructor is passed a reference to a object and the substring to find in the string. In this case, the example tries to determine whether recorded temperatures are in Fahrenheit or Celsius, and adds the appropriate introductory text to the beginning of the object. A random number generator is used to select an array that contains data in either degrees Celsius or degrees Fahrenheit.

code reference: System.Text.StringBuilder.Class#12

Call the method to convert the object to a object. You can search the string by using methods such as or , or you can use regular expressions and the class to search for patterns. Because both and objects use UTF-16 encoding to store characters, the index positions of characters, substrings, and regular expression matches are the same in both objects. This enables you to use methods to make changes at the same position at which that text is found in the object.

If you adopt this approach, you should work from the end of the object to its beginning so that you don't have to repeatedly convert the object to a string.

The following example illustrates this approach. It stores four occurrences of each letter of the English alphabet in a object. It then converts the text to a object and uses a regular expression to identify the starting position of each four-character sequence. Finally, it adds an underscore before each four-character sequence except for the first sequence, and converts the first character of the sequence to uppercase.

code reference: System.Text.StringBuilder.Class#13

Use the property to sequentially search a range of characters in a object. This approach may not be practical if the number of characters to be searched is large or the search logic is particularly complex.

The following example is identical in functionality to the previous example but differs in implementation. It uses the property to detect when a character value has changed, inserts an underscore at that position, and converts the first character in the new sequence to uppercase.

code reference: System.Text.StringBuilder.Class#14

Store all the unmodified text in the object, call the method to convert the object to a object, and perform the modifications on the object. You can use this approach if you have only a few modifications; otherwise, the cost of working with immutable strings may negate the performance benefits of using a object.

The following example is identical in functionality to the previous two examples but differs in implementation. It creates a object, converts it to a object, and then uses a regular expression to perform all remaining modifications on the string. The method uses a lambda expression to perform the replacement on each match.

code reference: System.Text.StringBuilder.Class#15

## Converting the StringBuilder object to a string

You must convert the object to a object before you can pass the string represented by the object to a method that has a parameter or display it in the user interface. You perform this conversion by calling the method. For an illustration, see the previous example, which calls the method to convert a object to a string so that it can be passed to a regular expression method.

Represents a mutable string of characters. This class cannot be inherited.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The string value of this instance is set to , and the capacity is set to the implementation-specific default capacity.

  Initializes a new instance of the class.

  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  is less than zero.

  The parameter defines the maximum number of characters that can be stored in the memory allocated by the current instance. Its value is assigned to the property. If the number of characters to be stored in the current instance exceeds this value, the object allocates additional memory to store them.

  The string value of this instance is set to . If is zero, the implementation-specific default capacity is used.

  Initializes a new instance of the class using the specified capacity.

  The suggested starting size of this instance.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  If is null, the new will contain the empty string (that is, it contains ).

  Initializes a new instance of the class using the specified string.

  The string used to initialize the value of the instance. If is null, the new will contain the empty string (that is, it contains ).
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The parameter defines the maximum number of characters that can be stored in the memory allocated by the current instance. Its value is assigned to the property. If the number of characters to be stored in the current instance exceeds this value, the object allocates additional memory to store them.

  If is zero, the implementation-specific default capacity is used.

  The property defines the maximum number of characters that the current instance can hold. Its value is assigned to the property. If the number of characters to be stored in the current instance exceeds this value, the object does not allocate additional memory, but instead throws an exception.

  Initializes a new instance of the class that starts with a specified capacity and can grow to a specified maximum.

  The suggested starting size of the .
  The maximum number of characters the current string can contain.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The parameter defines the maximum number of characters that can be stored in the memory allocated by the current instance. Its value is assigned to the property. If the number of characters to be stored in the current instance exceeds this value, the object allocates additional memory to store them.

  If is zero, the implementation-specific default capacity is used.

  Initializes a new instance of the class using the specified string and capacity.

  The string used to initialize the value of the instance. If is null, the new will contain the empty string (that is, it contains ).
  The suggested starting size of the .
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The parameter defines the maximum number of characters that can be stored in the memory allocated by the current instance. Its value is assigned to the property. If the number of characters to be stored in the current instance exceeds this value, the object allocates additional memory to store them.

  If is zero, the implementation-specific default capacity is used.

  Initializes a new instance of the class from the specified substring and capacity.

  The string that contains the substring used to initialize the value of this instance. If is null, the new will contain the empty string (that is, it contains ).
  The position within where the substring begins.
  The number of characters in the substring.
  The suggested starting size of the .
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#2

  The method calls the method to get the string representation of . The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified Boolean value to this instance.

  A reference to this instance after the append operation has completed.

  The Boolean value to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#3

  The method calls the method to get the string representation of for the current culture. To control the formatting of , call the method.

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified 8-bit unsigned integer to this instance.

  A reference to this instance after the append operation has completed.

  The value to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#4

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified Unicode character to this instance.

  A reference to this instance after the append operation has completed.

  The Unicode character to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder ``

  This method appends all the characters in the specified array to the current instance in the same order as they appear in . If is null, no changes are made.

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#6

  The capacity of this instance is adjusted as needed.

  Appends the string representation of the Unicode characters in a specified array to this instance.

  A reference to this instance after the append operation has completed.

  The array of characters to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#8

  The method calls the method to get the string representation of for the current culture. To control the formatting of , call the method.

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified decimal number to this instance.

  A reference to this instance after the append operation has completed.

  The value to append. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#9

  The method calls the method to get the string representation of for the current culture. To control the formatting of , call the method.

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified double-precision floating-point number to this instance.

  A reference to this instance after the append operation has completed.

  The value to append. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#10

  The method calls the method to get the string representation of for the current culture. To control the formatting of , call the method.

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified 16-bit signed integer to this instance.

  A reference to this instance after the append operation has completed.

  The value to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#11

  The method calls the method to get the string representation of for the current culture. To control the formatting of , call the method.

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified 32-bit signed integer to this instance.

  A reference to this instance after the append operation has completed.

  The value to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#12

  The method calls the to get the string representation of for the current culture. To control the formatting of , call the method.

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified 64-bit signed integer to this instance.

  A reference to this instance after the append operation has completed.

  The value to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates. It defines a Dog class, creates a Dog object, and makes three calls to the method to create a string that contains the dog's name and breed.

  code reference: System.Text.Stringbuilder.Append#18

  The method calls the method to get the string representation of . If is null, no changes are made to the object.

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified object to this instance.

  A reference to this instance after the append operation has completed.

  The object to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#13

  The method calls the method to get the string representation of for the current culture. To control the formatting of , call the method.

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified 8-bit signed integer to this instance.

  A reference to this instance after the append operation has completed.

  The value to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#14

  The method calls the method to get the string representation of for the current culture. To control the formatting of , call the method.

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified single-precision floating-point number to this instance.

  A reference to this instance after the append operation has completed.

  The value to append. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#2

  If is null, no changes are made.

  The capacity of this instance is adjusted as needed.

  Appends a copy of the specified string to this instance.

  A reference to this instance after the append operation has completed.

  The string to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#15

  The method calls the method to get the string representation of . To control the formatting of , call the method.

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified 16-bit unsigned integer to this instance.

  A reference to this instance after the append operation has completed.

  The value to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#16

  The calls the method to get the string representation of for the current culture. To control the formatting of , call the method.

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified 32-bit unsigned integer to this instance.

  A reference to this instance after the append operation has completed.

  The value to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Text.StringBuilder ``

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#17

  The method calls the method to get the string representation of for the current culture. To control the formatting of , call the method.

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified 64-bit unsigned integer to this instance.

  A reference to this instance after the append operation has completed.

  The value to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `` is less than zero.

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#5

  The capacity of this instance is adjusted as needed.

  Appends a specified number of copies of the string representation of a Unicode character to this instance.

  A reference to this instance after the append operation has completed.

  The character to append. The number of times to append . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `` `` is a null reference, and and are not both zero.

  or is less than zero.

  -or-

  The sum of and is greater than the length of .

  This method appends the specified range of characters in to the current instance. If is null and and are both zero, no changes are made.

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#7

  The capacity of this instance is adjusted as needed.

  Appends the string representation of a specified subarray of Unicode characters to this instance.

  A reference to this instance after the append operation has completed.

  A character array. The starting position in . The number of characters to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `` `` is a null reference, and and are not both zero.

  or is less than zero.

  -or-

  The sum of and is greater than the length of .

  This method appends the specified range of characters in to the current instance. If is null and and are both zero, no changes are made.

  The method modifies the existing instance of this class; it does not return a new class instance. 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 object, as the following example illustrates.

  code reference: System.Text.StringBuilder.Append#19

  The capacity of this instance is adjusted as needed.

  Appends a copy of a specified substring to this instance.

  A reference to this instance after the append operation has completed.

  The string that contains the substring to append. The starting position of the substring within . The number of characters in to append. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `` is a null reference. is invalid. `using System; using System.Text; public class StringBuilderTest { public static void Main() { StringBuilder sb = new StringBuilder("The high "); Console.WriteLine( sb.AppendFormat("temperature today was {0, 6}.", 88) ); } }`

  The output is

  `The high temperature today was 88.`

  This method uses the composite formatting feature of the .NET Framework to convert the value of an object to its text representation and embed that representation in the current object.

  The parameter consists of zero or more runs of text intermixed with zero or more indexed placeholders, called format items. The index of the format items must be 0, to correspond to , the single object in the parameter list of this method. The formatting process replaces each format item with the string representation of .

  The syntax of a format item is as follows:

  {index[,length][:formatString]}

  Elements in square brackets are optional. The following table describes each element.

  Element

  Description

  index

  The zero-based position in the parameter list of the object to be formatted. If the object specified by index is null, the format item is replaced by . If there is no parameter in the index position, a is thrown.

  ,length

  The minimum number of characters in the string representation of the parameter. If positive, the parameter is right-aligned; if negative, it is left-aligned.

  :formatString

  A standard or custom format string that is supported by the parameter.

  For the standard and custom format strings used with date and time values, see Standard Date and Time Format Strings and Custom Date and Time Format Strings. For the standard and custom format strings used with numeric values, see Standard Numeric Format Strings and Custom Numeric Format Strings. For the standard format strings used with enumerations, see Enumeration Format Strings.

  represents the object to be formatted. Each format item in is replaced with the string representation of . If the format item includes and implements the interface, then arg0.Format(formatString, null) defines the formatting. Otherwise, arg0.ToString() defines the formatting.

  If the string assigned to is "Thank you for your donation of {0:####} cans of food to our charitable organization." and is an integer with the value 10, the return value will be "Thank you for your donation of 10 cans of food to our charitable organization."

  Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a single argument.

  A reference to this instance with appended. Each format item in is replaced by the string representation of .

  A composite format string (see Remarks). An object to format. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `System.ParamArray` is a null reference. is invalid. `using System; using System.Text; public class StringBuilderTest { public static void Main() { string [] strings = {"very", "very", null, "high"}; StringBuilder sb = new StringBuilder("The high "); Console.WriteLine( sb.AppendFormat("temperature today was {0}, {1} {2}{3}.", strings) ); } }`

  The output is

  The high temperature today was very, very high.

  This method uses the composite formatting feature of the .NET Framework to convert the value of an object to its text representation and embed that representation in the current object.

  The parameter consists of zero or more runs of text intermixed with zero or more indexed placeholders, called format items, that correspond to objects in the parameter list of this method. The formatting process replaces each format item with the string representation of the corresponding object.

  The syntax of a format item is as follows:

  {index[,length][:formatString]}

  Elements in square brackets are optional. The following table describes each element.

  Element

  Description

  index

  The zero-based position in the parameter list of the object to be formatted. If the object specified by index is null, the format item is replaced by . If there is no parameter in the index position, a is thrown.

  ,length

  The minimum number of characters in the string representation of the parameter. If positive, the parameter is right-aligned; if negative, it is left-aligned.

  :formatString

  A standard or custom format string that is supported by the parameter.

  For the standard and custom format strings used with date and time values, see Standard Date and Time Format Strings and Custom Date and Time Format Strings. For the standard and custom format strings used with numeric values, see Standard Numeric Format Strings and Custom Numeric Format Strings. For the standard format strings used with enumerations, see Enumeration Format Strings.

  represents the objects to be formatted. Each format item in is replaced with the string representation of the corresponding object in . If the format item includes and the corresponding object in implements the interface, then args[index].Format(formatString, provider) defines the formatting. Otherwise, args[index].ToString(provider) defines the formatting.

  If the string assigned to is "Thank you for your donation of {0:####} cans of food to our charitable organization." and is an integer with the value 10, the return value will be "Thank you for your donation of 10 cans of food to our charitable organization."

  Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a corresponding argument in a parameter array.

  A reference to this instance with appended. Each format item in is replaced by the string representation of the corresponding object argument.

  A composite format string (see Remarks). An array of objects to format. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `` `System.ParamArray` or is a null reference. is invalid. `using System; using System.Text; public class StringBuilderTest { public static void Main() { string a = "very"; string b = "very"; string c = "high"; StringBuilder sb = new StringBuilder("The high "); Console.WriteLine(sb.AppendFormat(null, "temperature today was {0}, {1} {2}.", a, b, c) ); } }`

  The output is

  The high temperature today was very, very high.

  This method uses the composite formatting feature of the .NET Framework to convert the value of an object to its text representation and embed that representation in the current object.

  The parameter consists of zero or more runs of text intermixed with zero or more indexed placeholders, called format items, that correspond to objects in the parameter list of this method. The formatting process replaces each format item with the string representation of the corresponding object.

  The syntax of a format item is as follows:

  {index[,length][:formatString]}

  Elements in square brackets are optional. The following table describes each element.

  Element

  Description

  index

  The zero-based position in the parameter list of the object to be formatted. If the object specified by index is null, the format item is replaced by . If there is no parameter in the index position, a is thrown.

  ,length

  The minimum number of characters in the string representation of the parameter. If positive, the parameter is right-aligned; if negative, it is left-aligned.

  :formatString

  A standard or custom format string that is supported by the parameter.

  For the standard and custom format strings used with date and time values, see Standard Date and Time Format Strings and Custom Date and Time Format Strings. For the standard and custom format strings used with numeric values, see Standard Numeric Format Strings and Custom Numeric Format Strings. For the standard format strings used with enumerations, see Enumeration Format Strings.

  The parameter specifies an implementation that can provide formatting information for the objects in . can be any of the following:

  A object that provides culture-specific formatting information.

  A object that provides culture-specific formatting information for numeric values in .

  A object that provides culture-specific formatting information for date and time values in .

  A custom implementation that provides formatting information for one or more of the objects in . Typically, such an implementation also implements the interface. The second example in the next section illustrates an method call with a custom implementation.

  If the parameter is null, format provider information is obtained from the current culture.

  represents the objects to be formatted. Each format item in is replaced with the string representation of the corresponding object in . If the format item includes and the corresponding object in implements the interface, then args[index].Format(formatString, provider) defines the formatting. Otherwise, args[index].ToString(provider) defines the formatting.

  Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a corresponding argument in a parameter array using a specified format provider.

  A reference to this instance after the append operation has completed. After the append operation, this instance contains any data that existed before the operation, suffixed by a copy of where any format specification is replaced by the string representation of the corresponding object argument.

  An object that supplies culture-specific formatting information. A composite format string (see Remarks). An array of objects to format. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `` `` is a null reference. is invalid. `using System; using System.Text; public class StringBuilderTest { public static void Main() { StringBuilder sb = new StringBuilder("The high "); Console.WriteLine( sb.AppendFormat("temperature today was {0} {1}.", "very", "high") ); } }`

  The output is

  The high temperature today was very high.

  This method uses the composite formatting feature of the .NET Framework to convert the value of an object to its text representation and embed that representation in the current object.

  The parameter consists of zero or more runs of text intermixed with zero or more indexed placeholders, called format items, that correspond to and , the two objects in the parameter list of this method. The formatting process replaces each format item with the string representation of the corresponding object.

  The syntax of a format item is as follows:

  {index[,length][:formatString]}

  Elements in square brackets are optional. The following table describes each element.

  Element

  Description

  index

  The zero-based position in the parameter list of the object to be formatted. If the object specified by index is null, the format item is replaced by . If there is no parameter in the index position, a is thrown.

  ,length

  The minimum number of characters in the string representation of the parameter. If positive, the parameter is right-aligned; if negative, it is left-aligned.

  :formatString

  A standard or custom format string that is supported by the parameter.

  For the standard and custom format strings used with date and time values, see Standard Date and Time Format Strings and Custom Date and Time Format Strings. For the standard and custom format strings used with numeric values, see Standard Numeric Format Strings and Custom Numeric Format Strings. For the standard format strings used with enumerations, see Enumeration Format Strings.

  and represent the objects to be formatted. Each format item in is replaced with the string representation of either or . If the format item includes and the corresponding object implements the interface, then argx.ToString(formatString, provider) defines the formatting, where x is the index of the argument. Otherwise, argx.ToString(provider) defines the formatting.

  If the string assigned to is "Thank you for your donation of {0:####} cans of food to our charitable organization." and is an integer with the value 10, the return value will be "Thank you for your donation of 10 cans of food to our charitable organization."

  Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of two arguments.

  A reference to this instance with appended. Each format item in is replaced by the string representation of the corresponding object argument.

  A composite format string (see Remarks). The first object to format. The second object to format. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `` `` `` is a null reference. is invalid. `using System; using System.Text; public class StringBuilderTest { public static void Main() { StringBuilder sb = new StringBuilder("The high "); Console.WriteLine( sb.AppendFormat("temperature today was {0} {1} {2}.", "very", "very", "high") ); } }`

  The output is

  The high temperature today was very very high.

  This method uses the composite formatting feature of the .NET Framework to convert the value of an object to its text representation and embed that representation in the current object.

  The parameter consists of zero or more runs of text intermixed with zero or more indexed placeholders, called format items, that correspond to through , the objects in the parameter list of this method. The formatting process replaces each format item with the string representation of the corresponding object.

  The syntax of a format item is as follows:

  {index[,length][:formatString]}

  Elements in square brackets are optional. The following table describes each element.

  Element

  Description

  index

  The zero-based position in the parameter list of the object to be formatted. If the object specified by index is null, the format item is replaced by . If there is no parameter in the index position, a is thrown.

  ,length

  The minimum number of characters in the string representation of the parameter. If positive, the parameter is right-aligned; if negative, it is left-aligned.

  :formatString

  A standard or custom format string that is supported by the parameter.

  For the standard and custom format strings used with date and time values, see Standard Date and Time Format Strings and Custom Date and Time Format Strings. For the standard and custom format strings used with numeric values, see Standard Numeric Format Strings and Custom Numeric Format Strings. For the standard format strings used with enumerations, see Enumeration Format Strings.

  , , and represent the objects to be formatted. Each format item in is replaced with the string representation of either , , or , depending on the index of the format item. If the format item includes and the corresponding object in implements the interface, then argx.ToString(formatString, null) defines the formatting, where x is the index of the argument. Otherwise, argx.ToString() defines the formatting.

  If the string assigned to is "Thank you for your donation of {0:####} cans of food to our charitable organization." and is an integer with the value 10, the return value will be "Thank you for your donation of 10 cans of food to our charitable organization."

  Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of three arguments.

  A reference to this instance with appended. Each format item in is replaced by the string representation of the corresponding object argument.

  A composite format string (see Remarks). The first object to format. The second object to format. The third object to format. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Text.StringBuilder

  The default line terminator is the current value of the property.

  The capacity of this instance is adjusted as needed.

  Appends the default line terminator to the end of the current object.

  A reference to this instance after the append operation has completed.

- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Text.StringBuilder ``

  The default line terminator is the current value of the property.

  The capacity of this instance is adjusted as needed.

  Appends a copy of the specified string followed by the default line terminator to the end of the current object.

  A reference to this instance after the append operation has completed.

  The string to append.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A containing the maximum number of characters that can be contained in the memory allocated by the current instance.

  The value specified for a set operation is less than .

  does not affect the string value of the current instance. can be decreased as long as it is not less than .

  The dynamically allocates more space when required and increases accordingly. For performance reasons, a might allocate more memory than needed. The amount of memory allocated is implementation-specific.

  Gets or sets the maximum number of characters that can be contained in the memory allocated by the current instance.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Char `` To be added.

  Gets or sets the character at a specified position in the current instance.

  A containing the Unicode character at location in the current instance.

  is the position of a character within the . The first character in the string is at index 0. The length of a string is the number of characters it contains. The last accessible character of a instance is at the index - 1.

  is greater than or equal to the length of the current instance.

  -or-

  is less than zero.

  0
- Method
  4.0.0.0
  System.Text.StringBuilder

  is a convenience method that is equivalent to setting the property of the current instance to 0 (zero).

  Calling the method does not modify the current instance's or property.

  Removes all characters from the current instance.

  An object whose is 0 (zero).

- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Void `` `` `` ``

  The method is intended to be used in the rare situation when you need to efficiently copy successive sections of a object to an array. The array should be a fixed size, preallocated, reusable, and possibly globally accessible.

  For example, your application could populate a object with a large number of characters then use the method to copy small, successive pieces of the object to an array where the pieces are processed. When all the data in the object is processed, the size of the object is set to zero and the cycle is repeated.

  Copies the characters from a specified segment of this instance to a specified segment of a destination array.

  The starting position in this instance where characters will be copied from. The index is zero-based. The array where characters will be copied. The starting position in where characters will be copied. The index is zero-based. The number of characters to be copied.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` is less zero.

  If the current capacity is less than the parameter, memory for this instance is reallocated to hold at least number of characters; otherwise, no memory is changed.

  Ensures that the capacity of this instance of is at least the specified value.

  The new capacity of this instance.

  The minimum capacity to ensure. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` To be added.

  Returns a value indicating whether this instance is equal to a specified object.

  true if this instance and have equal string, , and values; otherwise, false.

  An object to compare with this instance, or null. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity is adjusted as needed.

  Inserts the string representation of a Boolean value into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  Inserts the string representation of a specified 8-bit unsigned integer into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero.

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  Inserts the string representation of a specified Unicode character into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero.

  Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  If is null, the is not changed.

  Inserts the string representation of a specified array of Unicode characters into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The character array to insert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  Inserts the string representation of a decimal number into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  Inserts the string representation of a double-precision floating-point number into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero.

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  Inserts the string representation of a specified 16-bit signed integer into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  Inserts the string representation of a specified 32-bit signed integer into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero.

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  Inserts the string representation of a 64-bit signed integer into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero.

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  If is null, the value of this instance is unchanged.

  Inserts the string representation of an object into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The object to insert, or null. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity is adjusted as needed.

  Inserts the string representation of a specified 8-bit signed integer into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  Inserts the string representation of a single-precision floating point number into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 1 ExtendedNumerics
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero.

  Existing characters are shifted to make room for the new text. The capacity is adjusted as needed.

  This instance of is not changed if is null, or is not null but its length is zero.

  Inserts a string into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The string to insert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero.

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  Inserts the string representation of a 16-bit unsigned integer into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero.

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  Inserts the string representation of a 32-bit unsigned integer into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Text.StringBuilder `` ``

  is greater than the length of the current instance

  -or-

  is less than zero.

  is used to get a string representation of . Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  Inserts the string representation of a 64-bit unsigned integer into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. The value to insert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `` ``

  is greater than the length of the current instance

  -or-

  is less than zero

  -or-

  is less than zero

  Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  This object is not changed if is null, is not null but its length is zero, or is zero.

  Inserts one or more copies of a specified string into this instance at the specified character position.

  A reference to this instance after insertion has completed.

  The position in this instance where insertion begins. The string to insert. The number of times to insert . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `` `` `` is a null reference, and and are not both zero.

  is greater than the length of the current instance or less than zero.

  -or-

  or is less than zero or their sum is greater than the length of .

  Existing characters are shifted to make room for the new text. The capacity of this instance is adjusted as needed.

  Inserts the string representation of a specified subarray of Unicode characters into this instance at the specified character position.

  A reference to this instance after the insert operation has completed.

  The position in this instance where insertion begins. A character array. The starting index within . The number of characters to insert. 0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A containing the length of the current instance.

  The value specified for a set operation is less than 0.

  Like the property, the property indicates the length of the current string object. Unlike the property, which is read-only, the property allows you to modify the length of the string stored to the object.

  If the specified length is less than the current length, the current object is truncated to the specified length. If the specified length is greater than the current length, the end of the string value of the current object is padded with the Unicode NULL character (U+0000).

  If the specified length is greater than the current capacity, increases so that it is greater than or equal to the specified length.

  Gets or sets the length of the current object.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 To be added.

  The maximum capacity for this implementation is . However, this value is implementation-specific and might be different in other or later implementations.

  In the net_v40_short and the net_v45, when you instantiate the object by calling the constructor, both the length and the capacity of the instance can grow beyond the value of its property. This can occur particularly when you call the and methods to append small strings.

  Gets the maximum capacity of this instance.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  or is less than zero

  -or-

  The sum of and is greater than the length of the current instance.

  `using System; using System.Text; public class StringBuilderTest { public static void Main() { StringBuilder sb = new StringBuilder("0123456789"); Console.WriteLine(sb); sb.Remove(3, 4); Console.WriteLine(sb); } }`

  The output is

  0123456789

  012789

  The current method removes the specified range of characters from the current instance. The characters at ( + ) are moved to , and the string value of the current instance is shortened by . The capacity of the current instance is unaffected.

  The method modifies the value of the current instance and returns that instance. It does not create and return a new object.

  Removes the specified range of characters from this instance.

  A reference to this instance after the excise operation has completed.

  The zero-based position in this instance where removal begins. The number of characters to remove. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` ``

  This method performs an ordinal, case-sensitive comparison to identify occurrences of in the current instance. The size of the current instance is unchanged after the replacement.

  Replaces all occurrences of a specified character in this instance with another specified character.

  A reference to this instance with replaced by .

  The character to replace. The character that replaces . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `` is a null reference. The length of is zero.

  This method performs an ordinal, case-sensitive comparison to identify occurrences of in the current instance. If is null or , all occurrences of are removed.

  Replaces all occurrences of a specified string in this instance with another specified string.

  A reference to this instance with all instances of replaced by .

  The string to replace. The string that replaces , or null. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `` `` ``

  The sum of and is larger than the length of the current instance

  -or-

  or is less than zero.

  This method performs an ordinal, case-sensitive comparison to identify occurrences of in the current instance. The size of the current object is unchanged after the replacement.

  Replaces, within a substring of this instance, all occurrences of a specified character with another specified character.

  A reference to this instance with replaced by in the range from to + -1.

  The character to replace. The character that replaces . The position in this instance where the substring begins. The length of the substring. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Text.StringBuilder `` `` `` ``

  is a null reference.

  or is less than zero.

  -or-

  The sum of and is greater than the length of the current instance.

  The length of is zero.

  This method performs an ordinal, case-sensitive comparison to identify occurrences of in the specified substring. If is null or , all occurrences of are removed.

  Replaces, within a substring of this instance, all occurrences of a specified string with another specified string.

  A reference to this instance with all instances of replaced by in the range from to + - 1.

  The string to replace. The string that replaces , or null. The position in this instance where the substring begins. The length of the substring. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  The parameter is reserved for future use and does not participate in this operation.

  For more information, see the method.

  Populates a object with the data necessary to deserialize the current object.

  The object to populate with serialization information. The place to store and retrieve serialized data. Reserved for future use.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  You must call the method to convert the object to a object before you can pass the string represented by the object to a method that has a parameter or display it in the user interface.

  Converts the value of this instance to a .

  A string whose value is the same as this instance.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` ``

  or is less than zero.

  -or-

  The sum of and is greater than the length of the current instance.

  You must call the method to convert the object to a object before you can pass the string represented by the object to a method that has a parameter or display it in the user interface.

  Converts the value of a substring of this instance to a .

  A string whose value is the same as the specified substring of this instance.

  The starting position of the substring in this instance. The length of the substring. 0
0