BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.Object System.Runtime.InteropServices.ComVisible(true)

The following example demonstrates using the implementation of the class to convert two byte arrays to a character array, where one character's bytes span multiple byte arrays. This demonstrates how to use a in streaming-like situations.

`using System; using System.Text; public class DecoderExample { public static void Main() { // These bytes in UTF-8 correspond to 3 different // Unicode characters - A (U+0041), # (U+0023), // and the biohazard symbol (U+2623). Note the // biohazard symbol requires 3 bytes in UTF-8 // (in hex, e2, 98, a3). Decoders store state across // multiple calls to GetChars, handling the case // when one char spans multiple byte arrays. byte[] bytes1 = { 0x41, 0x23, 0xe2 }; byte[] bytes2 = { 0x98, 0xa3 }; char[] chars = new char[3]; Decoder d = Encoding.UTF8.GetDecoder(); int charLen = d.GetChars(bytes1, 0, bytes1.Length, chars, 0); // charLen is 2. charLen += d.GetChars(bytes2, 0, bytes2.Length, chars, charLen); // charLen is now 3. foreach(char c in chars) Console.Write("U+{0:x} ", (ushort)c); } }`

The output is

U+41 U+23 U+2623

To obtain an instance of an implementation of the class, the application should use the method of an implementation.

The method determines how many characters result in decoding a sequence of bytes, and the method performs the actual decoding. There are several versions of both of these methods available in the class. For more information, see . A object maintains state information between successive calls to GetChars or methods so it can correctly decode byte sequences that span blocks. The also preserves trailing bytes at the end of data blocks and uses the trailing bytes in the next decoding operation. Therefore, and are useful for network transmission and file operations because those operations often deal with blocks of data instead of a complete data stream.

When the application is done with a stream of data, it should make sure that the state information is flushed by setting the parameter to true in the appropriate method call. If an exception occurs or if the application switches streams, it should call to clear the internal state of the Decoder object.

## Version Considerations

A or object can be serialized during a conversion operation. The state of the object is retained if it is deserialized in the same version of the .NET Framework, but lost if it is deserialized in another version.

Converts a sequence of encoded bytes into a set of characters.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  To obtain an instance of an implementation of this class, the application should use the method of a implementation.

  Initializes a new instance of the class.

  0
- Method
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Runtime.InteropServices.ComVisible(false)
  System.Void `` `` `` `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Void `` `` `` `` `` `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Property
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Text.DecoderFallback To be added.

  The object represents an error handler that is invoked when an encoded byte sequence cannot be converted to a character.

  Gets or sets a object for the current object.

- Property
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Text.DecoderFallbackBuffer To be added.

  The object represents data used by the object. The object represents an error handler that is invoked when an encoded byte sequence cannot be converted to a character.

  Gets the object associated with the current object.

- Method
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Runtime.InteropServices.ComVisible(false)
  System.Int32 `` `` ``

  This method does not affect the state of the decoder.

  To calculate the exact array size that requires to store the resulting characters, the application should use .

  If GetChars is called with set to false, the decoder stores trailing bytes at the end of the data block in an internal buffer and uses them in the next decoding operation. The application should call GetCharCount on a block of data immediately before calling GetChars on the same block, so that any trailing bytes from the previous block are included in the calculation.

  When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes starting at the specified byte pointer. A parameter indicates whether to clear the internal state of the decoder after the calculation.

  The number of characters produced by decoding the specified sequence of bytes and any bytes in the internal buffer.

  A pointer to the first byte to decode. The number of bytes to decode. true to simulate clearing the internal state of the encoder after the calculation; otherwise, false.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` `` `` is .

  < 0.

  -or-

  < 0.

  -or-

  and do not specify a valid range in (i.e. ( + ) > .Length).

  This method does not affect the state of the decoder.

  To calculate the exact array size that requires to store the resulting characters, the application should use .

  If GetChars is called with set to false, the decoder stores trailing bytes at the end of the data block in an internal buffer and uses them in the next decoding operation. The application should call GetCharCount on a block of data immediately before calling GetChars on the same block, so that any trailing bytes from the previous block are included in the calculation.

  When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.

  The number of characters produced by decoding the specified sequence of bytes and any bytes in the internal buffer.

  The byte array containing the sequence of bytes to decode. The index of the first byte to decode. The number of bytes to decode. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Int32 `` `` `` ``

  This method does not affect the state of the decoder.

  To calculate the exact array size that requires to store the resulting characters, the application should use .

  If GetChars is called with set to false, the decoder stores trailing bytes at the end of the data block in an internal buffer and uses them in the next decoding operation. The application should call GetCharCount on a block of data immediately before calling GetChars on the same block, so that any trailing bytes from the previous block are included in the calculation.

  When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes from the specified byte array. A parameter indicates whether to clear the internal state of the decoder after the calculation.

  The number of characters produced by decoding the specified sequence of bytes and any bytes in the internal buffer.

  The byte array containing the sequence of bytes to decode. The index of the first byte to decode. The number of bytes to decode. true to simulate clearing the internal state of the encoder after the calculation; otherwise, false.
- Method
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Runtime.InteropServices.ComVisible(false)
  System.Int32 `` `` `` `` ``

  Remember that the object saves state between calls to . When the application is done with a stream of data, it should set the parameter to true to make sure that the state information is flushed. With this setting, the decoder ignores invalid bytes at the end of the data block and clears the internal buffer.

  To calculate the exact buffer size that GetChars requires to store the resulting characters, the application should use .

  If GetChars is called with set to false, the decoder stores trailing bytes at the end of the data block in an internal buffer and uses them in the next decoding operation. The application should call GetCharCount on a block of data immediately before calling GetChars on the same block, so that any trailing bytes from the previous block are included in the calculation.

  If your application is to convert many segments of an input stream, consider using the method. will throw an exception if the output buffer isn't large enough, but will fill as much space as possible and return the bytes read and chars written. Also see the topic for more comments.

  When overridden in a derived class, decodes a sequence of bytes starting at the specified byte pointer and any bytes in the internal buffer into a set of characters that are stored starting at the specified character pointer. A parameter indicates whether to clear the internal state of the decoder after the conversion.

  The actual number of characters written at the location indicated by the parameter.

  A pointer to the first byte to decode. The number of bytes to decode. A pointer to the location at which to start writing the resulting set of characters. The maximum number of characters to write. true to clear the internal state of the decoder after the conversion; otherwise, false.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` `` `` `` ``

  does not contain sufficient space to store the decoded characters.

  is .

  -or-

  is .

  < 0.

  -or-

  < 0.

  -or-

  < 0.

  -or-

  and do not specify a valid range in (i.e. (+ ) > .Length).

  -or-

  > .Length.

  Remember that the object saves state between calls to . When the application is done with a stream of data, it should set the parameter to true to make sure that the state information is flushed. With this setting, the decoder ignores invalid bytes at the end of the data block and clears the internal buffer.

  To calculate the exact array size that GetChars requires to store the resulting characters, the application should use .

  If GetChars is called with set to false, the decoder stores trailing bytes at the end of the data block in an internal buffer and uses them in the next decoding operation. The application should call GetCharCount on a block of data immediately before calling GetChars on the same block, so that any trailing bytes from the previous block are included in the calculation.

  If your application is to convert many segments of an input stream, consider using the method. will throw an exception if the output buffer isn't large enough, but will fill as much space as possible and return the bytes read and chars written. Also see the topic for more comments.

  When overridden in a derived class, decodes a sequence of bytes from the specified byte array and any bytes in the internal buffer into the specified character array.

  The actual number of characters written into .

  The byte array containing the sequence of bytes to decode. The index of the first byte to decode. The number of bytes to decode. The character array to contain the resulting set of characters. The index at which to start writing the resulting set of characters. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Int32 `` `` `` `` `` ``

  Remember that the object saves state between calls to . When the application is done with a stream of data, it should set the parameter to true to make sure that the state information is flushed. With this setting, the decoder ignores invalid bytes at the end of the data block and clears the internal buffer.

  To calculate the exact array size that GetChars requires to store the resulting characters, the application should use .

  If GetChars is called with set to false, the decoder stores trailing bytes at the end of the data block in an internal buffer and uses them in the next decoding operation. The application should call GetCharCount on a block of data immediately before calling GetChars on the same block, so that any trailing bytes from the previous block are included in the calculation.

  If your application is to convert many segments of an input stream, consider using the method. will throw an exception if the output buffer isn't large enough, but will fill as much space as possible and return the bytes read and chars written. Also see the topic for more comments.

  When overridden in a derived class, decodes a sequence of bytes from the specified byte array and any bytes in the internal buffer into the specified character array. A parameter indicates whether to clear the internal state of the decoder after the conversion.

  The actual number of characters written into the parameter.

  The byte array containing the sequence of bytes to decode. The index of the first byte to decode. The number of bytes to decode. The character array to contain the resulting set of characters. The index at which to start writing the resulting set of characters. true to clear the internal state of the decoder after the conversion; otherwise, false.
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Void

  This method clears the internal state of the object. The method clears any state information preserved from a previous call to or , including trailing bytes at the end of the previous data block.

  Your application should call the method if it wants to reuse the same decoder even after an exception is thrown by , , or , or if the decoder switches streams and begins to decode another stream.

  When overridden in a derived class, sets the decoder back to its initial state.

0