Is it possible to detect a Nullable type (cast into an object) when it is null?
Since Nullable<T> is really a struct I think it should be possible.
double? d = null;
var s = GetValue(d); //I want this to return "0" rather than ""
public string GetValue(object o)
{
if(o is double? && !((double?)o).HasValue) //Not working with null
return "0";
if(o == null)
return "";
return o.ToString();
}
http://msdn.microsoft.com/en-us/library/ms228597(v=vs.80).aspx
and
So you either have a
doubleor anull.