private static string Alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"abcdefghijklmnopqrstuvwxyz";
private static readonly int CharsAmount = Alphabet.Length;
public static void Main(string[] args)
static string GetBase62(Int64 base10)
bool isNegative = base10 < 0;
decimal value = Math.Abs(base10);
string base62 = GetChar(value).ToString();
while (value >= CharsAmount)
value = Math.Floor(value / CharsAmount);
base62 = GetChar(value) + base62;
static char GetChar(decimal value)
int fraction = (int) (value % CharsAmount);
return Alphabet[fraction];
static void TryTest(Int64 value)
Console.WriteLine($"{value}(10) == {GetBase62(value)}({CharsAmount})");
Console.WriteLine($"value:{value} error:{e.Message}");