Convert integer to hexadecimal and back again

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

    To Hex:

    string hex = intValue.ToString("X");
    

    To int:

    int intValue = int.Parse(hex, System.Globalization.NumberStyles.HexNumber)
    

提交回复
热议问题