Class StringBuilder

Provides a mechanism to concatenate strings. The StringBuilder class represents a mutable string of characters and provides a mechanism to concatenate a sequence of strings.

see

{@link http://msdn.microsoft.com/en-us/library/bb310852(v=vs.100).aspx}

Index

Constructor methods

Methods

Constructor methods

constructor(initialText?: string): StringBuilder

Creates a new instance of StringBuilder and optionally accepts initial text to concatenate. You can specify a string in the optional initialText parameter to initialize the value of the StringBuilder instance.

Parameters

  • initialText?: string optional
          (Optional) The string that is used to initialize the value of the instance. If the value is null, the new StringBuilder instance will contain an empty string ("").
    

Returns

StringBuilder

Methods

public append(text: string)

Appends a copy of a specified string to the end of the Sys.StringBuilder instance. Use the append method to append a copy of a specified string to the end of a StringBuilder instance. If text is an empty string, null, or undefined, the StringBuilder instance remains unchanged.

Parameters

  • text: string
            The string to append to the end of the StringBuilder instance.
    

public appendLine(text: string)

Appends a string with a line terminator to the end of the Sys.StringBuilder instance. Use the appendLine method to append a specified string and a line terminator to the end of a Stringbuilder instance. The line terminator is a combination of a carriage return and a newline character. If no string is specified in text, only the line terminator is appended.

Parameters

  • text: string
          (Optional) The string to append with a line terminator to the end of the StringBuilder instance.
    

public clear()

Clears the contents of the Sys.StringBuilder instance. Use the clear method to clear the StringBuilder instance of its current contents.

public isEmpty(): boolean

Determines whether the Sys.StringBuilder object has content. Use the isEmpty method to determine whether a StringBuilder instance has any content. If you append an empty string, null, or an undefined value to an empty StringBuilder instance, the instance remains empty and unchanged.

Returns

boolean

true if the StringBuilder instance contains no elements; otherwise, false.

public toString(separator?: string): string

Creates a string from the contents of a Sys.StringBuilder instance, and optionally inserts a delimiter between each element of the created string. Use the toString method to create a string from the contents of a StringBuilder instance. Use the toString method with the optional separator parameter to insert a specified string delimiter between each element of the created string.

Parameters

  • separator?: string optional
          (Optional) A string to append between each element of the string that is returned.
    

Returns

string

A string representation of the StringBuilder instance. If separator is specified, the delimiter string is inserted between each element of the returned string.