Convert integer to hexadecimal and back again

前端 未结 10 2305
轮回少年
轮回少年 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:35

    int to hex:

    int a = 72;

    Console.WriteLine("{0:X}", a);

    hex to int:

    int b = 0xB76;

    Console.WriteLine(b);

提交回复
热议问题