Cast the current instance to the given type. the cast is dynamically tested for safety

C# | Visual Basic | Visual C++ |
public static TInstance SafeCastTo<TInstance>( this Id id ) where TInstance : class, IManagedWrapper
<ExtensionAttribute> _ Public Shared Function SafeCastTo(Of TInstance As {Class, IManagedWrapper}) ( _ id As Id _ ) As TInstance
[ExtensionAttribute] public: generic<typename TInstance> where TInstance : ref class, IManagedWrapper static TInstance SafeCastTo( Id^ id )

- TInstance
- The type of the instance.

- id (Id)
[Missing <param name="id"/> documentation for "M:Monobjc.IdExtensions.SafeCastTo``1(Monobjc.Id)"]

The cast instance or null if the reference is null

In Visual Basic and C#, you can call this method as an instance method on any object of type Id. When you use instance method syntax to call this method, omit the first parameter.

Exception | Condition |
---|---|
ObjectiveCClassCastException | If an error occured during the cast |

- Available in Monobjc Bridge: 10.6 (For Mac OS X 10.6 and later), 10.5 (For Mac OS X 10.5 and later)