通过字符串获得double?

2017-01-25 17:20:05  访问(1317) 赞(0) 踩(0)


        /// <summary>
        /// 通过字符串获得double?
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public double? GetDoubleNullByStr(string str, double? defaultValue)
        {
            if (str == null || str.Length == 0)
                return null;

            double theResult = double.MinValue;

            if (double.TryParse(str, out theResult))
                return theResult;

            return defaultValue;
        }


标签:通过字符串获得double? 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)