Convert integer to hexadecimal and back again

前端 未结 10 2373
轮回少年
轮回少年 2020-11-22 02:33

How can I convert the following?

2934 (integer) to B76 (hex)

Let me explain what I am trying to do. I have User IDs in my database that are stored as inte

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 02:37

    int valInt = 12;
    Console.WriteLine(valInt.ToString("X"));  // C  ~ possibly single-digit output 
    Console.WriteLine(valInt.ToString("X2")); // 0C ~ always double-digit output
    

提交回复
热议问题