Namespace: System.Text
Provides fundamental types for manipulating strings and byte arrays, including encoding and decoding text.
StringBuilder Class
Represents a mutable sequence of characters. This class is designed for performance when you need to perform a large number of appends or modifications to a string.
Members:
Append(string value)
: Appends the string representation of a value to the end of this instance.AppendLine()
: Appends the default line terminator to the end of this instance.Clear()
: Removes all characters from the current StringBuilder instance.ToString()
: Converts this instance to a string.
Encoding Class
Represents a text encoding. Encoding and decoding can be performed by calling the appropriate methods of subclasses of the Encoding class.
Methods:
GetString(byte[] bytes)
: Converts an array of bytes to an equivalent string.GetBytes(string s)
: Converts a string to an array of bytes.GetChars(byte[] bytes)
: Converts an array of bytes to an array of characters.
Common Encodings:
Encoding.UTF8
: Gets an instance of the UTF-8 encoding.Encoding.Unicode
: Gets an instance of the UTF-16 little-endian encoding.Encoding.ASCII
: Gets an instance of the ASCII encoding.
Decoder Class
Decodes a sequence of byte arrays into a sequence of characters.
Methods:
GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
: Converts a range of bytes, starting at byteIndex and containing byteCount bytes, into a sequence of characters.
Encoder Class
Encodes a sequence of characters into a sequence of byte arrays.
Methods:
GetByteCount(char[] chars, int index, int count)
: Returns the number of bytes produced by the Encoder.GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, bool flush)
: Converts a range of characters into a sequence of bytes.
ASCIIEncoding Class
Represents the ASCII (American Standard Code for Information Interchange) character encoding.
UTF8Encoding Class
Represents the UTF-8 encoding of the Unicode character set.
UnicodeEncoding Class
Represents the UTF-16 little-endian encoding of the Unicode character set.