コード例 #1
0
        public static bool ConvertToNumber(string aValue, CultureInfo Culture, out double Result, out TNumberFormat NumberFormat)
        {
            string sValue;

            NumberFormat = new TNumberFormat(aValue, Culture, out sValue);
            bool Converted = CFConvertToNumber(sValue, out Result, Culture);

            if (Converted && NumberFormat.HasPercent)
            {
                Result /= 100;
            }
            return(Converted);
        }
コード例 #2
0
        public static bool ConvertToNumber(string aValue, CultureInfo Culture, out double Result, out TNumberFormat NumberFormat)
        {
            string sValue;

            NumberFormat = new TNumberFormat(aValue, Culture, out sValue);

            if (MissingFrameworkDoubleTryParse)
            {
                bool Converted = CFConvertToNumber(sValue, out Result, Culture);
                if (Converted && NumberFormat.HasPercent)
                {
                    Result /= 100;
                }
                return(Converted);
            }

            bool ConversionOk = false;

            Result = 0;

            try
            {
                ConversionOk = NormalConvertToNumber(sValue, out Result, Culture);
            }
            catch (MissingMethodException)
            {
                MissingFrameworkDoubleTryParse = true;
            }

            if (MissingFrameworkDoubleTryParse)
            {
                ConversionOk = CFConvertToNumber(sValue, out Result, Culture);
            }

            if (ConversionOk && NumberFormat.HasPercent)
            {
                Result /= 100;
            }

            return(ConversionOk);
        }