Convert from base62 to decimal integer in C #

less than 1 minute read

As the title suggests, convert from Base62 to decimal integer in C #.

static int Convert62To10(string input)
{
    string BASE62STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

    int retval = 0;

    foreach (char c in input)
    {
        retval *= 62;
        retval += BASE62STRING.IndexOf(c);
    }
    return retval;
}

Tags:

Updated: