StringBuilder class

From Catglobe Wiki
Revision as of 06:24, 7 April 2015 by Tungocman (talk | contribs)
Jump to: navigation, search

StringBuilder



An equivalent to the stringbuilder class in dotnet, in that it is not invariant, and thus manipulations are fast.

Constructors

  • () - Create a new empty string

Methods

  • StringBuilder Append(string str "String to append") - Append to current string
  • StringBuilder AppendFormat(params AnyType) - Format the first param with the other parameters given and append to current string
  • string this[] { get; }(number index "The key used to lookup the value.") - Get the char at the given index.
  • StringBuilder Remove(number startIndex "The zero-based position in this instance where removal begins.", number length "The number of characters to remove") - Removes the specified range of characters from this instance.
  • StringBuilder Replace(string oldValue "The string to replace.", string newValue "The string that replaces oldValue or Empty.") - Replaces all occurrences of a specified string in this instance with another specified string.
  • StringBuilder Replace(string oldValue "The string to replace.", string newValue "The string that replaces oldValue or Empty.", number startIndex "The position in this instance where the substring begins.", number count "The length of the substring.") - Replaces, within a substring of this instance, all occurrences of a specified string with another specified string.
  • Empty this[] { set; }(number index "The key used to lookup the value.", string value "The value to set.") - Set the char at the given index to the value given.
  • string Substring(number startIndex "The position in this instance where the substring begins.", number length "The length of the substring.") - Returns a substring in the string.
  • string ToString() - The string representation of the object.

Properties

  • string ObjectTypeName { get; } - The name of the type of object.
  • TypeInformation TypeInformation { get; } - Get information about this class.


Examples

String s = "My name is: {0} {1} {2}"; String firstName = "Nam"; String middleName = "Van"; String lastName = "Nguyen";

StringBuilder sb; sb.Append("Hello! "); sb.AppendFormat(s, firstName, middleName, lastName); print(sb.ToString()); // Hello! My name is: Nam Van Nguyen