Partager via


Class.Cast(Object) Method

Definition

Casts an object to the class or interface represented by this Class object.

[Android.Runtime.Register("cast", "(Ljava/lang/Object;)Ljava/lang/Object;", "")]
public Java.Lang.Object? Cast (Java.Lang.Object? obj);
[<Android.Runtime.Register("cast", "(Ljava/lang/Object;)Ljava/lang/Object;", "")>]
member this.Cast : Java.Lang.Object -> Java.Lang.Object

Parameters

obj
Object

the object to be cast

Returns

the object after casting, or null if obj is null

Attributes

Exceptions

if the object cannot be cast to the given type.

Remarks

Casts an object to the class or interface represented by this Class object.

Added in 1.5.

Java documentation for java.lang.Class.cast(java.lang.Object).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to