GetDefaultShortAllowDefaultConversion() публичный статический Метод

Get default short allow default conversion
public static GetDefaultShortAllowDefaultConversion ( ) : bool
Результат bool
Пример #1
0
 /// <summary>
 /// <para>Convert string to short</para>
 /// <para>set default value on error</para>
 /// </summary>
 /// <param name="strValue">string value</param>
 /// <param name="defaultValue">default value</param>
 /// <returns>converted value or default value</returns>
 public static short TryParseShort(this string strValue, short defaultValue)
 {
     return(strValue.TryParseShort(defaultValue,
                                   BasePrimitivesExtensions.GetDefaultShortAllowDefaultConversion(),
                                   BasePrimitivesExtensions.GetDefaultShortNumberStyle(),
                                   BasePrimitivesExtensions.GetCurrentCulture()));
 }
Пример #2
0
        /// <summary>
        /// <para>Try parse object short to short value</para>
        /// </summary>
        /// <param name="objValue">object to convert</param>
        /// <param name="defaultValue">default return value</param>
        /// <returns>short result</returns>
        public static short TryParseShort(this object objValue, short defaultValue)
        {
            if (objValue == null)
            {
                return(defaultValue);
            }

            try
            {
                return(objValue.ToString().TryParseShort(defaultValue,
                                                         BasePrimitivesExtensions.GetDefaultShortAllowDefaultConversion(),
                                                         BasePrimitivesExtensions.GetDefaultShortNumberStyle(),
                                                         BasePrimitivesExtensions.GetCurrentCulture()));
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(defaultValue);
            }
        }
Пример #3
0
 /// <summary>
 /// Convert string to short
 /// </summary>
 /// <param name="strValue">string value</param>
 /// <param name="numberStyle">number style to convert</param>
 /// <param name="culture">culture origin</param>
 /// <returns>converted value or BasePrimitivesExtensions.GetDefaultShortConversionValue value</returns>
 public static short TryParseShort(this string strValue, NumberStyles numberStyle, CultureInfo culture)
 {
     return(strValue.TryParseShort(BasePrimitivesExtensions.GetDefaultShortConversionValue(),
                                   BasePrimitivesExtensions.GetDefaultShortAllowDefaultConversion(),
                                   numberStyle, culture));
 }