Partilhar via


IGuardedOperations.TryCastToType<TArgs>(Object, TArgs) Method

Definition

Safely attempts to cast the given object to the given type.

public:
generic <typename TArgs>
 bool TryCastToType(System::Object ^ toCast, [Runtime::InteropServices::Out] TArgs % casted);
public bool TryCastToType<TArgs> (object toCast, out TArgs casted);
abstract member TryCastToType : obj * 'Args -> bool
Public Function TryCastToType(Of TArgs) (toCast As Object, ByRef casted As TArgs) As Boolean

Type Parameters

TArgs

The type that should be casted to.

Parameters

toCast
Object

The object that should be casted.

casted
TArgs

Returns out the casted object or default(TArgs) if the cast failed.

Returns

True if successful in casting, false otherwise.

Applies to