str转成double? - DoubleByStr

2017-01-25 17:29:07  访问(1356) 赞(0) 踩(0)



        /// <summary>
        /// str转成double?
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public double DoubleByStr(string str, double defaultValue)
        {
            if (str == null)
                return defaultValue;

            if (str.Length == 0)
                return defaultValue;

            double theResult = 0;

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

            return defaultValue;
        }


标签:str转成double? - DoubleByStr 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)