ConvertibleExtensionsToTypeDefault Method

Converts the value of this instance to an Object of the specified Type by calling one of the named conversions from IConvertible, such as ToChar(IFormatProvider) or ToDouble(IFormatProvider).

Definition

Namespace: Jodosoft.Primitives
Assembly: Jodosoft.Primitives (in Jodosoft.Primitives.dll) Version: 2.0
public static Object ToTypeDefault(
	this IConvertible value,
	Type targetType,
	IFormatProvider? provider
)

Parameters

value  IConvertible
The IConvertible to convert.
targetType  Type
The Type to which the value of this instance is converted.
provider  IFormatProvider
An IFormatProvider interface implementation that supplies culture-specific formatting information.

Return Value

Object
An Object instance of type conversionType whose value is equivalent to the value of this instance.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IConvertible. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This method does not call ToType(Type, IFormatProvider) so that it can be used as a default implementation for that method.

Exceptions

ArgumentNullExceptionIf value or targetType are null.
InvalidCastExceptionIf the value cannot be converted using a method from IConvertible.

See Also