06.HighQualityMethodsHomework/RefactorCSharpPart2Exam/11. CSharp-Part-2-Exam/CSharp-Part-2-Exam/EnigmaCat/EnigmaCat.cs
/// <summary>
/// Convert a number in a specified base to decimal number
/// </summary>
/// <param name="number">Number to convert as string</param>
/// <param name="baseNum">Base to convert from as an unsigned 64-bit-integer</param>
/// <returns>Converted number in decimal system as an unsigned 64-bit-integer</returns>
Convert a number in a specified base to decimal number
Convert a number in a specified base to decimal number
private static ulong ConvertToDecimal(string number, ulong baseNum)
        {
            ulong result = 0;
            for (int i = number.Length - 1; i >= 0; i--)
            {
                ulong digit = (ulong)((ulong)(number[i] - 'a') % baseNum);
                result += digit * NumberToPower(baseNum, (uint)(number.Length - 1 - i));
            }
            return result;
        }
private static ulong ConvertToDecimal ( string number , ulong baseNum ) { ulong result = 0 ; for ( int i = number . Length - 1 ; i >= 0 ; i -- ) { ulong digit = ( ulong ) ( ( ulong ) ( number [ i ] - ' ' ) % baseNum ) ; result += digit * NumberToPower ( baseNum , ( uint ) ( number . Length - 1 - i ) ) ; } return result ; }
Convert a number in a specified base to decimal number
Convert a number in a specified base to decimal number
// Convert to decimal using the standard formula for conversion
Converted number in decimal system as an unsigned 64-bit-integer
Converted number in decimal system as an unsigned 64 - bit - integer
number
string
Number to convert as string
Number to convert as string
baseNum
ulong
Base to convert from as an unsigned 64-bit-integer
Base to convert from as an unsigned 64 - bit - integer