How will this be achieved?
Personally, I would just get rid of your general method. It is valid for only two type arguments - break it into an overloaded method with two overloads:
internal static double? RoundNullable(double? nullable, int decimals)
{
return nullable.HasValue ? Math.Round(nullable.Value, decimals)
: (double?) null;
}
internal static decimal? RoundNullable(decimal? nullable, int decimals)
{
return nullable.HasValue ? Math.Round(nullable.Value, decimals)
: (decimal?) null;
}
, , , dynamic, # 4 .NET 4.