public static GetDefaultDecimalConversionValue ( ) : decimal | ||
return | decimal |
/// <summary> /// Convert decimal string value in decimal value /// </summary> /// <param name="strValue">string to convert</param> /// <returns>decimal value</returns> public static decimal TryParseDecimal(this string strValue) { return(strValue.TryParseDecimal( BasePrimitivesExtensions.GetDefaultDecimalConversionValue(), BasePrimitivesExtensions.GetDefaultDecimalAllowDefaultConversion(), BasePrimitivesExtensions.GetDefaultDecimalNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture())); }
/// <summary> /// Parse string array in decimal array /// </summary> /// <param name="strValue">string to parse</param> /// <param name="defaultValue">default value when default tryparse</param> /// <param name="allowDefaultConversion">Allow default tryparse values</param> /// <param name="numberStyle">number style to convert</param> /// <param name="culture">culture origin</param> /// <returns>decimal array</returns> public static decimal[] TryParseDecimalArray(this string strValue, decimal[] defaultValue, bool allowDefaultConversion, NumberStyles numberStyle, CultureInfo culture) { if (String.IsNullOrEmpty(strValue)) { return defaultValue ?? new decimal[] { } } ; var decimalList = defaultValue != null ? defaultValue.ToList() : new List <decimal>(); foreach (var l in strValue.Split(',')) { var strDecimal = l ?? ""; if (String.IsNullOrEmpty(strDecimal)) { if (allowDefaultConversion) { decimalList.Add(BasePrimitivesExtensions.GetDefaultDecimalConversionValue()); } continue; } decimal decimalConvert; if (!decimal.TryParse(strDecimal, numberStyle, culture, out decimalConvert)) { if (allowDefaultConversion) { decimalList.Add(BasePrimitivesExtensions.GetDefaultDecimalConversionValue()); } } else { decimalList.Add(decimalConvert); } } return(decimalList.ToArray()); }
/// <summary> /// <para>Try parse decimal to decimal value</para> /// <para>Default value is BasePrimitivesExtensions.GetDefaultDecimalConversionValue() value</para> /// </summary> /// <param name="objValue">object to convert</param> /// <returns>decimal result</returns> public static decimal TryParseDecimal(this object objValue) { return(objValue.TryParseDecimal(BasePrimitivesExtensions.GetDefaultDecimalConversionValue())); }
/// <summary> /// Convert decimal string value in decimal value /// </summary> /// <param name="strValue">string to convert</param> /// <param name="numberStyle">number style to convert</param> /// <param name="culture">decimal culture origin</param> /// <returns>decimal value</returns> public static decimal TryParseDecimal(this string strValue, NumberStyles numberStyle, CultureInfo culture) { return(strValue.TryParseDecimal(BasePrimitivesExtensions.GetDefaultDecimalConversionValue(), BasePrimitivesExtensions.GetDefaultDecimalAllowDefaultConversion(), numberStyle, culture)); }