C#Socket发16进制以及进制转换

string input = "Hello World!";
char[] values = input.ToCharArray();
foreach (char letter in values)
{
    // Get the integral value of the character.
    int value = Convert.ToInt32(letter);
    // Convert the decimal value to a hexadecimal value in string form.
    string hexOutput = String.Format("{0:X}", value);
    Console.WriteLine("Hexadecimal value of {0} is {1}", letter, hexOutput);

以上为字符转为16进制; 

posted @ 2019-09-17 18:54  搬砖的L先生  阅读(1452)  评论(0编辑  收藏  举报