I\'ve been asked to export a list of users from ActiveDirectory, and Convert the GUIDs to a numeric equivalent for display (so I\'ll .ToString that after). I\'ve done some searc
"Numeric" doesn't make sense in VB w.r.t Guid
. There is no 128-bit numeric types in .net. The only 128-bit type is Decimal; but that doesn't seem to make sense to convert a Guid
to a Decimal
. I would simply use ToByteArray
and display the byte values as hex.
Alternatively, make sure the last byte in the array given to BigInteger is zero to get a postive value. e.g.::
var bytes = Guid.NewGuid().ToByteArray();
Array.Resize(ref bytes, 17);
var bigInt = new BigInteger(bytes);
var value = bigInt.ToString();
You could simply convert Guid to numeric representation using ToString("n") :
Guid.NewGuid().ToString("n")
will return something like "5ee575bd995b419499aff6d6967c4a35"