Skip to content

Conversions from ASCII to hex to decimal, all 3

barry 0

Asked Mar 20, 2007, 11:21 AM EDT1 answer
Share
LinkedInX
I need to create a C# program that does the following:

Converts a character such as 'S' to 0x53 or 83 decimal and I need to print it on the screen as
char  hex  decimal
 S     53    83
can anyone help.
thanks,
barry

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Mike Gold
    0
    C#
    using System;
    using System.Collections.Generic;
    using System.Text;
    namespace testhex
    {
    class Program
    {
    static void Main(string[] args)
    {
    char c = 'S';
    Console.WriteLine("{0} {1} {2}", c, ((int) c).ToString("x"), ((int) c).ToString());
    Console.ReadLine();
    }
    }
    }
    0