閱讀英文

共用方式為


Decoder 建構函式

定義

初始化 Decoder 類別的新執行個體。

C#
protected Decoder();

範例

下列範例示範兩種初始化新 Decoder 實例的技術。

C#
using System;
using System.Text;

class EncoderExample {
    public static void Main() {
        // A Decoder is obtained from an Encoding.
        UnicodeEncoding uni = new UnicodeEncoding();
        Decoder dec1 = uni.GetDecoder();

        // A more direct technique.
        Decoder dec2 = Encoding.Unicode.GetDecoder();

        // dec1 and dec2 seem to be the same.
        Console.WriteLine(dec1.ToString());
        Console.WriteLine(dec2.ToString());

        // Note that their hash codes differ.
        Console.WriteLine(dec1.GetHashCode());
        Console.WriteLine(dec2.GetHashCode());
    }
}

/* This code example produces the following output.

System.Text.UnicodeEncoding+Decoder
System.Text.UnicodeEncoding+Decoder
58225482
54267293

*/

備註

若要取得這個類別的實作實例,應用程式應該使用 GetDecoder 實作的 Encoding 方法。

適用於

另請參閱