Encoder Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the Encoder class.
protected:
Encoder();
protected Encoder ();
Protected Sub New ()
Examples
The following example demonstrates two techniques for initializing a new Encoder instance.
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
'
Remarks
To obtain an instance of an implementation of this class, the application should use the GetEncoder method of an Encoding implementation.
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET