Convert<T>(object, Func<T>) Method
Converts the provided value to the specified type. This method never throws an exception. It will return the specified default value if the value cannot be converted to T.
Namespace
Statiq.Common
Containing Type
TypeHelper

Syntax

public static T Convert<T>(object value, Func<T> defaultValueFactory)

Type Parameters

Name Description
T The desired return type.

Parameters

Name Type Description
value object The value to convert.
defaultValueFactory Func<T> A factory to get a default value if the value cannot be converted to type T.

Return Value

Type Description
T The value converted to type T or the specified default value if the value cannot be converted to type T.