JavaPeerableExtensions.JavaAs<TResult>(IJavaPeerable) Method

Definition

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

C#
public static TResult? JavaAs<TResult> (this Java.Interop.IJavaPeerable? self) where TResult : class, Java.Interop.IJavaPeerable;

Type Parameters

TResult

The type to coerce self to.

Parameters

self
IJavaPeerable

A IJavaPeerable instance to coerce to type TResult.

Returns

TResult

A value of type TResult if the Java peer to self can be coerced to the Java type corresponding to TResult; otherwise, null.

Exceptions

The Java peer type for TResult could not be found.

The type TResult or a Invoker type for TResult does not provide an activation constructor, a constructor with a singature of (ref JniObjectReference, JniObjectReferenceOptions) or (IntPtr, JniHandleOwnership).

Remarks

Applies to

Product Versions
.NET for Android .NET for Android API 35

See also

  • <xref:Java.Interop.JavaPeerableExtensions.TryJavaCast%60%601(Java.Interop.IJavaPeerable)>