Skip to content

BindingTypeConverterDispatch.TryConvertAny(object?, Type, object?, Type, object?, object?) method

Defined in

Type: BindingTypeConverterDispatch Namespace: ReactiveUI Assembly: ReactiveUI.Core.dll

Applies to

net10.0, net10.0-maccatalyst26.0, net10.0-desktop1.0, net10.0-browserwasm1.0, net10.0-tvos26.0, net10.0-windows10.0.19041, net10.0-macos26.0, net10.0-ios26.0, net10.0-android36.0, net9.0, net9.0-tvos18.0, net9.0-macos15.0, net9.0-maccatalyst18.0, net9.0-windows10.0.19041, net9.0-ios18.0, net9.0-desktop1.0, net8.0, net8.0-windows10.0.19041, net8.0-ios18.0, net8.0-maccatalyst18.0, net8.0-macos15.0, net8.0-tvos18.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.5, netstandard2.1, net481, net462, net471

public static bool TryConvertAny(object? converter, Type fromType, object? from, Type toType, object? conversionHint, out object? result)

View source

Summary: Attempts to convert an object to a specified target type using the provided converter.

Parameters

NameTypeDescription
converterobject?The converter instance to use for the conversion. Must implement either IBindingTypeConverter or IBindingFallbackConverter. If null or of an unsupported type, the conversion will not be performed.
fromTypeTypeThe type of the source object to convert. Used to determine the appropriate conversion logic.
fromobject?The source object to convert. May be null if the converter supports null values.
toTypeTypeThe target type to convert the source object to. Cannot be null.
conversionHintobject?An optional hint or context object that may influence the conversion process. The interpretation of this value depends on the converter implementation.
out resultobject?When this method returns, contains the converted value if the conversion succeeded; otherwise, null. This parameter is passed uninitialized.

Returns: bool -- true if the conversion was successful and result contains the converted value; otherwise, false.

Remarks

This method supports both type-based and fallback converters. If the provided converter does not implement a supported interface or is null, the method returns false and result is set to null. The method does not throw exceptions for failed conversions; instead, it returns false to indicate failure.