I would have the bin/oct/dec/hex values of ulong values as string. So I have to use convert.tostring(, base) with desired base. To support this, I cast the ulong value to long, while long is supported with convert.tostring(, base) to have the bin/oct/dec/hex value as string for ulong. Am I right?
//while Convert.ToString does not support ulong with base
//Convert.ToString(ulong.MaxValue, 2);
// following code sample is the same like not supported ToString on line 2, right?
ulong ul = ulong.Maxvalue;
long l = (long)ul;
Convert.ToString(l, 8); //8 => oct, 2 => bin
OK, for dec, I just can use ul.ToString(); for Hex, ul.ToString("X");
Based on, Copy bits from ulong to long in C# I'm a little confused. Does this give me the correct Oct and Bin string representation for ulong?
related gist: https://gist.github.com/chubbson/375b535243c166d28119