How do I check is the type class or struct?
protected T GetNullValue<T>(IDataReader reader, int ordinalId)
{
if (reader.IsDBNull(ordinalId))
{
//if T is struct.....
//else if I is class
}
return (T)reader.GetValue(ordinalId);
}
if (default(T) is ValueType)
...
is the most efficient thing I can come up with at the moment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With