13

Quick question...

I have a stupidly long BigInteger which I would like to write to a file as a hex string.

I know Java provides the .toString(16) method which does this, but I can't find an equivalent in C#.

I'm using System.Numerics.BigInteger from .NET 4.0.

Thanks

Blacktempel
  • 3,817
  • 3
  • 27
  • 50
Ozzah
  • 10,581
  • 15
  • 73
  • 114

2 Answers2

17

Use .ToString("X") or .ToString("x") depending on what case you prefer.

Gabe
  • 82,547
  • 12
  • 135
  • 231
5

Can you not use yourBI.ToString("X")?

http://msdn.microsoft.com/en-us/library/dd268260.aspx

Brad
  • 152,561
  • 47
  • 332
  • 504