ConvertibleExtensionsTo(IConvertible, Type, IFormatProvider) Method

Converts the given IConvertible value to the specified type using the provided CultureInfo. Handles conversion to various common types and throws an exception if the conversion cannot be performed.

Definition

Namespace: FileHold.LibraryManager.Extensions
Assembly: FileHold.LibraryManager (in FileHold.LibraryManager.dll) Version: 17.2.0.0
C#
public static Object To(
	this IConvertible value,
	Type targetType,
	IFormatProvider formatProvider = null
)

Parameters

value  IConvertible
The IConvertible value to be converted.
targetType  Type
formatProvider  IFormatProvider  (Optional)
The CultureInfo to use for the conversion.

Return Value

Object
The converted value of type.

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).

Exceptions

InvalidCastExceptionThrown when attempting to convert a null value to a value type.
ExceptionThrown when the conversion cannot be performed using IConvertible methods.

See Also