C# Program to find the ASCII Value of a Character

Problem

Write a program in Visual C# to find the ASCII value of the input character.

How to find the ASCII value of a character in C# ?

using System;

namespace AbundantcodeApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Abundantcode.com coding sample");
            Console.Write("Enter a character : ");
            char input = char.Parse(Console.ReadLine());
            // casting to convert the integer representation of the character
            int asciiValue = (int)input;
            Console.WriteLine(asciiValue);
            Console.ReadLine();
        }
    }
}

Output

Abundantcode.com coding sample

Enter a character : A

65

Tags :

Leave Your Comment

Liked this content?. Please spread the word :)