public static int ObjectToInt(object obj)
{
return ((obj != DBNull.Value && obj != null && Microsoft.VisualBasic.Information.IsNumeric(obj)) ? Convert.ToInt32(obj) : 0);
}
public static string ObjectToString(object obj)
{
return ((obj != DBNull.Value && obj != null) ? obj.ToString() : "");
}
public static DateTime ObjectToDateTime(object obj)
{
return (Microsoft.VisualBasic.Information.IsDate(obj) ? Convert.ToDateTime(obj) : new DateTime((long)0));
}
public static bool ObjectToBool(object obj)
{
return ((obj != DBNull.Value && obj != null) ? (obj != "" ? Convert.ToBoolean(obj) : false) : false);
}
public static decimal ObjectDecimal(object obj)
{
return ((obj != DBNull.Value && obj != null && Microsoft.VisualBasic.Information.IsNumeric(obj)) ? Convert.ToDecimal(obj) : 0);
}
答案 0 :(得分:-2)
public static int ObjectToInt(object obj)
{
return ((obj != DBNull.Value && obj != null && Microsoft.VisualBasic.Information.IsNumeric(obj)) ? Convert.ToInt32(obj) : 0);
}
public static string ObjectToString(object obj)
{
return ((obj != DBNull.Value && obj != null) ? obj.ToString() : "");
}
public static DateTime ObjectToDateTime(object obj)
{
return (Microsoft.VisualBasic.Information.IsDate(obj) ? Convert.ToDateTime(obj) : new DateTime((long)0));
}
public static bool ObjectToBool(object obj)
{
return ((obj != DBNull.Value && obj != null) ? (obj != "" ? Convert.ToBoolean(obj) : false) : false);
}
public static decimal ObjectDecimal(object obj)
{
return ((obj != DBNull.Value && obj != null && Microsoft.VisualBasic.Information.IsNumeric(obj)) ? Convert.ToDecimal(obj) : 0);
}