Convert byte array to ASCII string in CSharp

Description

The following code shows how to convert byte array to ASCII string.

Example


using System;/*from  w  w  w  . ja va 2s .c  om*/
using System.Text;

class StringEncodingApp {
    static void Main(string[] args) {
        byte[] ba = new byte[] { 72, 101, 108, 108, 111 };
        string s = Encoding.ASCII.GetString(ba);
        Console.WriteLine(s);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Development »




Console
Encoding
Environment
Random