共用方式為


System.Text Namespace

Microsoft Silverlight will reach end of support after October 2021. Learn more.

The System.Text namespace contains classes that represent Unicode character encodings; abstract base classes for converting blocks of characters to and from blocks of bytes; and a helper class that manipulates and formats String objects without creating intermediate instances of String.

The encoding classes are primarily intended to convert between different encodings or code pages and a Unicode encoding. Encoding.Unicode (UTF-16) encoding is used internally by the .NET Framework, and Encoding.UTF8 encoding is often used for storing character data to ensure portability across machines and cultures.

The StringBuilder class is designed for operations that perform extensive manipulations on a single string. Unlike the String class, the StringBuilder class is mutable and provides better performance when concatenating or deleting strings.

For more information about System.Text, see Character Encoding in the .NET Framework and the MSDN blog Shawn Steele's Thoughts about Windows and .NET Framework Globalization APIs.

Classes

  Class Description
Public class Decoder Converts a sequence of encoded bytes into a set of characters.
Public class DecoderFallbackException The exception that is thrown when a decoder fallback operation fails. This class cannot be inherited.
Public class Encoder Converts a set of characters into a sequence of bytes.
Public class EncoderFallbackException The exception that is thrown when an encoder fallback operation fails. This class cannot be inherited.
Public class Encoding Represents a character encoding.
Public class StringBuilder Represents a mutable string of characters. This class cannot be inherited.
Public class UnicodeEncoding Represents a UTF-16 encoding of Unicode characters.
Public class UTF8Encoding Represents a UTF-8 encoding of Unicode characters.