using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace utils
{
///
/// string 扩展函数
///
public static class StringExtensions
{
///
/// str转int扩展函数
///
/// 转换失败返回默认值
///
public static int ToInt32(this string value, int defaultValue = 0)
{
int result;
if (int.TryParse(value, out result))
{
return result;
}
else
{
return defaultValue;
}
}
}
}