Encoder 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 Encoder 類別的新執行個體。
protected:
Encoder();
protected Encoder ();
Protected Sub New ()
範例
下列範例示範兩種初始化新 Encoder 實例的技術。
using namespace System;
using namespace System::Text;
int main()
{
// An Encoder is obtained from an Encoding.
UnicodeEncoding^ uni = gcnew UnicodeEncoding;
Encoder^ enc1 = uni->GetEncoder();
// A more direct technique.
Encoder^ enc2 = Encoding::Unicode->GetEncoder();
// enc1 and enc2 seem to be the same.
Console::WriteLine( enc1 );
Console::WriteLine( enc2 );
// Note that their hash codes differ.
Console::WriteLine( enc1->GetHashCode() );
Console::WriteLine( enc2->GetHashCode() );
}
/* This code example produces the following output.
System.Text.EncoderNLS
System.Text.EncoderNLS
54267293
18643596
*/
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.
Console.WriteLine(enc1.ToString());
Console.WriteLine(enc2.ToString());
// Note that their hash codes differ.
Console.WriteLine(enc1.GetHashCode());
Console.WriteLine(enc2.GetHashCode());
}
}
/* This code example produces the following output.
System.Text.EncoderNLS
System.Text.EncoderNLS
58225482
54267293
*/
Imports System.Text
Class EncoderExample
Public Shared Sub Main()
' An Encoder is obtained from an Encoding.
Dim uni As New UnicodeEncoding()
Dim enc1 As Encoder = uni.GetEncoder()
' A more direct technique.
Dim enc2 As Encoder = Encoding.Unicode.GetEncoder()
' enc1 and enc2 seem the same.
Console.WriteLine(enc1.ToString())
Console.WriteLine(enc2.ToString())
' Note that their hash codes differ.
Console.WriteLine(enc1.GetHashCode())
Console.WriteLine(enc2.GetHashCode())
End Sub
End Class
'This code example produces the following output.
'System.Text.EncoderNLS
'System.Text.EncoderNLS
'58225482
'54267293
'
備註
若要取得這個類別的實作實例,應用程式應該使用 GetEncoder 實作的 Encoding 方法。