I was to dynamically return the default value of a type, but I can't pass the default keyword a variable of type Type.
Why not?
Eg:
private object GetSpecialDefaultValue(Type theType)
{
if (theType == typeof (string))
{
return String.Empty;
}
if (theType == typeof (int))
{
return 1;
}
return default(theType);
}
Gives me the compile time error:
The type or namespace name 'theType' could not be found (are you missing a using directive or an assembly reference?)