Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

C# Sharp Exercises: Get the ASCII value of a given character

C# Sharp Basic: Exercise-76 with Solution

Write a C# Sharp program to get the ASCII value of a given character.

Sample Solution:

C# Sharp Code:

using System;
using System.Linq;
namespace exercises
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Ascii value of 1 is: "+test('1'));
            Console.WriteLine("Ascii value of A is: " + test('A'));
            Console.WriteLine("Ascii value of a is: " + test('a'));
            Console.WriteLine("Ascii value of # is: " + test('#'));

        }
        public static int test(char ch)
        {
            return (int)ch;
        }
    }
}

Sample Output:

Ascii value of 1 is: 49
Ascii value of A is: 65
Ascii value of a is: 97
Ascii value of # is: 35

Flowchart:

Flowchart: C# Sharp Exercises - Get the ASCII value of a given character.

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

Previous: Write a C# Sharp program which takes a positive number and return the nth odd number.
Next: Write a C# Sharp program to check whether a given word is plural or not.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.