LanguagePrimitives.TryConvertTo LanguagePrimitives.TryConvertTo LanguagePrimitives.TryConvertTo Method

Definition

Overloads

TryConvertTo(Object, Type, Object) TryConvertTo(Object, Type, Object) TryConvertTo(Object, Type, Object)

Sets result to valueToConvert converted to resultType.

TryConvertTo(Object, Type, IFormatProvider, Object) TryConvertTo(Object, Type, IFormatProvider, Object) TryConvertTo(Object, Type, IFormatProvider, Object)

Sets result to valueToConvert converted to resultType considering formatProvider for custom conversions, calling the Parse method and calling Convert.ChangeType.

TryConvertTo<T>(Object, T) TryConvertTo<T>(Object, T) TryConvertTo<T>(Object, T)

Sets result to valueToConvert converted to resultType.

TryConvertTo<T>(Object, IFormatProvider, T) TryConvertTo<T>(Object, IFormatProvider, T) TryConvertTo<T>(Object, IFormatProvider, T)

Sets result to valueToConvert converted to resultType considering formatProvider for custom conversions, calling the Parse method and calling Convert.ChangeType.

TryConvertTo(Object, Type, Object) TryConvertTo(Object, Type, Object) TryConvertTo(Object, Type, Object)

Sets result to valueToConvert converted to resultType.

public static bool TryConvertTo (object valueToConvert, Type resultType, out object result);
static member TryConvertTo : obj * Type *  -> bool
Public Shared Function TryConvertTo (valueToConvert As Object, resultType As Type, ByRef result As Object) As Boolean
Parameters
valueToConvert
Object Object Object

value to be converted and returned

resultType
Type Type Type

type to convert valueToConvert

result
Object Object Object

result of the conversion. This is valid only if the return is true.

Returns

false for conversion failure, true for success

Remarks

This method is a variant of ConvertTo that does not throw exceptions if the conversion fails.

TryConvertTo(Object, Type, IFormatProvider, Object) TryConvertTo(Object, Type, IFormatProvider, Object) TryConvertTo(Object, Type, IFormatProvider, Object)

Sets result to valueToConvert converted to resultType considering formatProvider for custom conversions, calling the Parse method and calling Convert.ChangeType.

public static bool TryConvertTo (object valueToConvert, Type resultType, IFormatProvider formatProvider, out object result);
static member TryConvertTo : obj * Type * IFormatProvider *  -> bool
Public Shared Function TryConvertTo (valueToConvert As Object, resultType As Type, formatProvider As IFormatProvider, ByRef result As Object) As Boolean
Parameters
valueToConvert
Object Object Object

value to be converted and returned

resultType
Type Type Type

type to convert valueToConvert

formatProvider
IFormatProvider IFormatProvider IFormatProvider

governing conversion of types

result
Object Object Object

result of the conversion. This is valid only if the return is true.

Returns

false for conversion failure, true for success

Remarks

This method is a variant of ConvertTo that does not throw exceptions if the conversion fails.

TryConvertTo<T>(Object, T) TryConvertTo<T>(Object, T) TryConvertTo<T>(Object, T)

Sets result to valueToConvert converted to resultType.

public static bool TryConvertTo<T> (object valueToConvert, out T result);
static member TryConvertTo : obj *  -> bool
Public Shared Function TryConvertTo(Of T) (valueToConvert As Object, ByRef result As T) As Boolean
Type Parameters
T
Parameters
valueToConvert
Object Object Object

value to be converted and returned

result

result of the conversion. This is valid only if the return is true.

Returns

false for conversion failure, true for success

Remarks

This method is a variant of ConvertTo that does not throw exceptions if the conversion fails.

TryConvertTo<T>(Object, IFormatProvider, T) TryConvertTo<T>(Object, IFormatProvider, T) TryConvertTo<T>(Object, IFormatProvider, T)

Sets result to valueToConvert converted to resultType considering formatProvider for custom conversions, calling the Parse method and calling Convert.ChangeType.

public static bool TryConvertTo<T> (object valueToConvert, IFormatProvider formatProvider, out T result);
static member TryConvertTo : obj * IFormatProvider *  -> bool
Public Shared Function TryConvertTo(Of T) (valueToConvert As Object, formatProvider As IFormatProvider, ByRef result As T) As Boolean
Type Parameters
T
Parameters
valueToConvert
Object Object Object

value to be converted and returned

formatProvider
IFormatProvider IFormatProvider IFormatProvider

governing conversion of types

result

result of the conversion. This is valid only if the return is true.

Returns

false for conversion failure, true for success

Remarks

This method is a variant of ConvertTo that does not throw exceptions if the conversion fails.

Applies to