必须是静态类的静态方法 参数必须使用this指定是哪种类型的拓展方法
public static class Common
{
/// <summary>
/// 转换Object类型为string,null为空值
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
public static string Conversion(object val)
{
if (val == DBNull.Value)
return "";
else if (val == null)
return "";
else
return val.ToString();
}
public static int ToInt(this object val)
{
int i = 0;
try
{
i = Convert.ToInt32(val);
}
catch{}
return i;
}
}