This documentation is archived and is not being maintained.

Encoder.Encoder Constructor

Initializes a new instance of the Encoder class.

Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)

protected Encoder ()
protected Encoder ()
protected function Encoder ()
Not applicable.

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

The following example demonstrates two techniques for initializing a new Encoder instance.

using System;
using System.Text;

class EncoderExample {
    public static void Main() {
        // An Encoder is obtained from an Encoding.
        UnicodeEncoding uni = new UnicodeEncoding();
        Encoder enc1 = uni.GetEncoder();

        // A more direct technique.
        Encoder enc2 = Encoding.Unicode.GetEncoder();

        // enc1 and enc2 seem to be the same.

        // Note that their hash codes differ.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0