通过str获得int?值 - IntNullByStr
2017-01-25 17:31:54 访问(1594) 赞(0) 踩(0)
/// <summary>
/// 通过str获得int?值
/// </summary>
/// <param name="str"></param>
/// <param name="defaultValue"></param>
/// <returns></returns>
public int? IntNullByStr(string str, int? defaultValue)
{
if (str == null)
return null;
if (str.Length == 0)
return null;
int theResult = 0;
if (int.TryParse(str, out theResult))
return theResult;
return defaultValue;
}
标签:
通过str获得int?值 - IntNullByStr 


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