I know the "default" keyword returns the default value of a statically determined type, as shown for instance in this question.
However, given an instance of a type, is there a simple way to get the default value of this type, dynamically ? The only way I found while googling is this :
static object DefaultValue(Type myType)
{
if (!myType.IsValueType)
return null;
else
return Activator.CreateInstance(myType);
}
But I'd like to avoid the Activator class if possible.