This documentation is archived and is not being maintained.

ASCIIEncoding Constructor

Initializes a new instance of the ASCIIEncoding class.

[Visual Basic]
Public Sub New()
public ASCIIEncoding();
public: ASCIIEncoding();
public function ASCIIEncoding();


[Visual Basic, C#, C++] The following example demonstrates how to create a new ASCIIEncoding instance and display the encoding name to the console.

[Visual Basic] 
Imports System
Imports System.Text

Class ASCIIEncodingExample   
    Public Shared Sub Main()
        Dim ascii As New ASCIIEncoding()
        Dim encodingName As String = ascii.EncodingName
        Console.WriteLine("Encoding name: " & encodingName)
    End Sub
End Class

using System;
using System.Text;

class ASCIIEncodingExample {
    public static void Main() {
        ASCIIEncoding ascii = new ASCIIEncoding();
        String encodingName = ascii.EncodingName;
        Console.WriteLine("Encoding name: " + encodingName);

#using <mscorlib.dll>
using namespace System;
using namespace System::Text;

int main() 
   ASCIIEncoding* ascii = new ASCIIEncoding();
   String * encodingName = ascii -> EncodingName;
   Console::WriteLine(S"Encoding name: {0}", encodingName);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

ASCIIEncoding Class | ASCIIEncoding Members | System.Text Namespace