IGuardedOperations.TryCastToType<TArgs>(Object, TArgs) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.