How to convert Ascii value to character in C# ?

In C# , you can convert the Ascii value to its corresponding character by assigning the value to a character .

How to convert Ascii value to character in C# ?

Below is a sample sourcecode to demo how to convert Ascii value to character in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{ 
    class Program
    {
        static void Main(string[] args)
        {
            char charData;
            // 98 is the ascii value for b
            charData = (char)98;
            // This will display c
            Console.WriteLine(charData);
            Console.ReadLine();
        }
    }
}
Tags :

2 Comments

  • your code is very clear and easy one .

  • I spent 20 minutes trying to find the answer (char)32.
    This is an incredibly convoluted subject for C#.
    When asking the question of how to convert a space as seen above, everybody wants to supply a small program of their own design. I found no answers which just supply the simple conversion.

    Thanks.
    By the way, this website would be a lot better if it stopped trying to send the reader to another website.
    I’ve tried blocking the crap with an adblocker, but it’s on a timer. Whomever coded that is an absolute jackass. For example: while typing this, I had to click “Back” about 10 times because this timer keeps redirecting my browser to https://developerpublish.com/category/csharp/.
    That’s really really bad form.

Leave Your Comment