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:
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.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework