str转成double?

2017-01-25 17:25:57  访问(1316) 赞(0) 踩(0)


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

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

            str = str.Trim();

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

            double theResult = 0;

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

            return null;
        }


标签:str转成double? 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)
 
  ┈全部┈  
 
(显示默认分类)