コード例 #1
0
        public virtual int ConvertToRadix10(string RadixStringToConvert, int RadixValue, char CharacterToRemove)
        {
            int Radix10Value = 0;

            RadixStringToConvert = StringHelper.ReverseString(RadixStringToConvert);
            RadixStringToConvert = StringHelper.TrimAndRemoveSpecifiedCharacterFromString(RadixStringToConvert, CharacterToRemove);

            for (int Counter = 0; Counter < RadixStringToConvert.Length; Counter++)
            {
                Radix10Value += (int)Math.Pow(RadixValue, Counter) * NumberSystemHelper.MyNumberConverter(RadixStringToConvert[Counter]);
            }

            return(Radix10Value);
        }
コード例 #2
0
        public virtual int ConvertToRadix10(string RadixStringToConvert, RadixNumber_ENUM Radix)
        {
            int Radix10Value = 0;

            RadixStringToConvert = StringHelper.ReverseString(RadixStringToConvert);

            for (int Counter = 0; Counter < RadixStringToConvert.Length; Counter++)
            {
                //if (RadixNumber_ENUM.HEXADECIMAL_NUMBER == Radix)
                //{
                //    Radix10Value += (int)Math.Pow((int)Radix, Counter) * int.Parse(RadixStringToConvert[Counter].ToString(),
                //        System.Globalization.NumberStyles.HexNumber);
                //}
                //else
                //{
                //    Radix10Value += (int)Math.Pow((int)Radix, Counter) * (int)Char.GetNumericValue(RadixStringToConvert[Counter]);
                //}

                Radix10Value += (int)Math.Pow((int)Radix, Counter) * NumberSystemHelper.MyNumberConverter(RadixStringToConvert[Counter]);
            }

            return(Radix10Value);
        }