Can a Generic Method handle both Reference and Nullable Value types?
- by Adam Lassek
I have a series of Extension methods to help with null-checking on IDataRecord objects, which I'm currently implementing like this:
public static int? GetNullableInt32(this IDataRecord dr, int ordinal)
{
int? nullInt = null;
return dr.IsDBNull(ordinal) ? nullInt : dr.GetInt32(ordinal);
}
public static int? GetNullableInt32(this…