toTypeWithDefault<T> static method
Converts value into an object type specified by Type Code or returns default value when conversion is not possible.
type
the TypeCode for the data type into which 'value' is to be converted.value
the value to convert.defaultValue
the default value to return if conversion is not possible (returns null). Returns object value of type corresponding to TypeCode, or default value when conversion is not supported.
See toNullableType See toTypeCode
Implementation
static T toTypeWithDefault<T>(TypeCode type, value, T defaultValue) {
var result = TypeConverter.toNullableType<T>(type, value);
return result ?? defaultValue;
}