📅  最后修改于: 2022-03-11 14:49:19.459000             🧑  作者: Mango
static void Main(string[] args)
{
int? i = GetValueOrNull(null, string.Empty);
}
public static Nullable GetValueOrNull(DbDataRecord reader, string columnName) where T : struct
{
object columnValue = reader[columnName];
if (!(columnValue is DBNull))
return (T)columnValue;
return null;
}