str转成double? - DoubleNullByStr
2017-01-25 17:26:55 访问(1336) 赞(0) 踩(0)
/// <summary>
/// str转成double?
/// </summary>
/// <param name="str"></param>
/// <param name="defaultValue"></param>
/// <returns></returns>
public double? DoubleNullByStr(string str,double? defaultValue)
{
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 defaultValue;
}
标签:
str转成double? - DoubleNullByStr 


上一条:
下一条:
相关评论
发表评论