Wanted a simple but efficient method to get value from Nullable when T is not known at the compile time.
So far have something like this:
public static object UnwrapNullable(object o)
{
if (o == null)
return null;
if (o.GetType().IsGenericType && o.GetType().GetGenericTypeDefinition() == typeof(Nullable<>))
return ???
return o;
}
anything can be done here without dipping into dynamic code generation?
used on .NET 2.0