必须是静态类的静态方法 参数必须使用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;
}
}

 

相关文章:

  • 2021-06-02
  • 2022-12-23
  • 2021-12-20
  • 2021-09-01
  • 2021-12-28
  • 2022-01-21
  • 2021-06-19
  • 2022-12-23
猜你喜欢
  • 2021-08-10
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2021-08-31
  • 2021-07-17
相关资源
相似解决方案