关于.Net类型转换
public static T ChangeType<T>(object value)
{
Type conversionType = typeof(T);
if (value is DBNull)
{
return default(T);
}
if (conversionType.IsGenericType && conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
{
if (value == null) { return default(T); }
conversionType = Nullable.GetUnderlyingType(conversionType); ;
}
return (T)Convert.ChangeType(value, conversionType);
}