Code sample

The convert() method converts a number to the specified base.
Here is the C# version.
I coded it by hand because the .NET library currently offers
only binary, octal or hexadecimal conversions.
private string convert(long num, int newBase)
   int d;
   char[] digits = {'0', '1', '2', '3', '4', '5', '6', '7',
                    '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
   StringBuilder output = new StringBuilder();
   // calculate the new output digits, working right to left
   while (num > 0)
    d = (int)(num % newBase);   // calculate the current output digit
    output.Append(digits[d]);   // append the digit's character to the result string
    num /= newBase;             // divide the input number by the base
   // reverse the output buffer and return it as a string
   return reverse(output.ToString());
private string reverse(string str)
   char[] c = str.ToCharArray();
   return new string(c);
The Java version, for comparison.
Much easier, and not restricted to running on Windows!
private String convert(long num, int newBase)
  return Long.toString(num, newBase);