I have the C# method
private static string TypeNameLower(object o)
{
return o.GetType().Name.ToLower();
}
to give me the lower case type name of the input object.
But if input is a string set to null or a nullable int set to null then this method of course fails.
How do I get the type name in this situation?
Jeff is correct. That’s like asking what kind of cake would have been in an empty box with no label.
As an alternative to Fortran’s answer you could also do:
That way, C# will pick the generic one at compile time if it knows enough about the type you’re passing in.