How to print the hex value of a character in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main()
    {
        char ch = 'a';
        
        string hex = BitConverter.ToString(new byte[] { Convert.ToByte(ch) });
        
        Console.WriteLine(hex);
    }
}


/*
run:

61

*/

 



answered Mar 6, 2019 by avibootz

Related questions

1 answer 191 views
1 answer 95 views
1 answer 92 views
92 views asked Jan 3, 2025 by avibootz
1 answer 161 views
1 answer 175 views
1 answer 161 views
...