Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ASCIIEncoding Constructor

Initializes a new instance of the ASCIIEncoding class.

[Visual Basic]
Public Sub New()
[C#]
public ASCIIEncoding();
[C++]
public: ASCIIEncoding();
[JScript]
public function ASCIIEncoding();

Example

[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

[C#] 
using System;
using System.Text;

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

[C++] 
#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.

Requirements

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

Show:
© 2015 Microsoft