편집

다음을 통해 공유


TextBuilder Data type

Version: Available or changed with runtime version 1.0.

Represents a lighweight wrapper for the .Net implementation of StringBuilder.

Instance methods

The following methods are available on instances of the TextBuilder data type.

Method name Description
Append(Text) Appends a copy of the specified string to this TextBuilder instance.
AppendLine([Text]) Appends a copy of the specified string followed by the default line terminator to the end of the current TextBuilder object. If this parameter is omitted, only the line terminator will be appended.
Capacity([Integer]) Gets or sets the maximum number of characters that can be contained in the memory allocated by the current instance.
Clear() Removes all characters from the current TextBuilder instance.
EnsureCapacity(Integer) Ensures that the capacity of this TextBuilder instance is at least the specified value.
Insert(Integer, Text) Inserts a string into this TextBuilder instance at the specified character position.
Length([Integer]) Gets or sets the length of this TextBuilder instance.
MaxCapacity() Gets the maximum capacity of this TextBuilder instance.
Remove(Integer, Integer) Removes the specified range of characters from this TextBuilder instance.
Replace(Text, Text) Replaces all occurrences of a specified string in this TextBuilder instance with another specified string.
Replace(Text, Text, Integer, Integer) Replaces, within a substring of this instance, all occurrences of a specified string in this TextBuilder instance with another specified string.
ToText() Converts the value of this TextBuilder instance to a Text.
ToText(Integer, Integer) Converts the value of a substring of this TextBuilder instance to a Text.

Remarks

The TextBuilder data type is one-based indexed, that is, the indexing begins with 1.

The Text Data Type is a value type, such that every time you use a method on it, you create a new string object in memory. This requires a new allocation of space. In situations where you need to perform repeated modifications to a string, the overhead associated with creating a Text Data Type can be costly.

The TextBuilder data type is a reference type, which holds a pointer elsewhere in memory. For performance reasons, we recommend you to use it when you want to modify a string without creating a new object. For example, using TextBuilder data type can boost performance when concatenating many strings together in a loop.

Get Started with AL
Developing Extensions
Text Data Type