ConvertibleExtensionsToT(IConvertible, IFormatProvider) Method

Converts the given IConvertible value to the specified type T 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 T To<T>(
	this IConvertible value,
	IFormatProvider formatProvider = null
)

Parameters

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

Type Parameters

T
The type to convert the value to.

Return Value

T
The converted value of type T.

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