c# nullable generic code example
Example: c# nullable generic
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;
}