How to convert numbers between hexadecimal and decimal

前端 未结 17 1398
情歌与酒
情歌与酒 2020-11-22 05:30

How do you convert between hexadecimal numbers and decimal numbers in C#?

17条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 06:05

    If it's a really big hex string beyond the capacity of the normal integer:

    For .NET 3.5, we can use BouncyCastle's BigInteger class:

    String hex = "68c7b05d0000000002f8";
    // results in "494809724602834812404472"
    String decimal = new Org.BouncyCastle.Math.BigInteger(hex, 16).ToString();
    

    .NET 4.0 has the BigInteger class.

提交回复
热议问题