# ToObjectArray

> Converts a managed array of System.IntPtr, representing Java objects, to a Java array of \<tt\>java.lang.Object\</tt\>.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/7000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.AndroidJNIModule

## ToObjectArray(IntPtr\*, int, IntPtr)

Converts a managed array of System.IntPtr, representing Java objects, to a Java array of \\\<tt\\>java.lang.Object\\\</tt\\>.

```csharp
public static nint ToObjectArray(nint* array, int length, nint arrayClass)
```

### Parameters

**** (\[IntPtr\*]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): The managed array to convert.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of elements in the array.**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): The class of the array's elements.

### Returns

| Type                                                           | Description                                                      |
| -------------------------------------------------------------- | ---------------------------------------------------------------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) | A local reference to the newly constructed Java array of object. |

### Remarks

Additional Resources: [AndroidJNI.NewObjectArray](/engine/7000.0/script-reference/unityengine/androidjni/newobjectarray.md), [AndroidJNI.SetObjectArrayElement](/engine/7000.0/script-reference/unityengine/androidjni/setobjectarrayelement.md)

## ToObjectArray(IntPtr\[], IntPtr)

Converts a managed array of System.IntPtr, representing Java objects, to a Java array of `java.lang.Object`.

```csharp
public static nint ToObjectArray(nint[] array, nint arrayClass)
```

### Parameters

**** (\[IntPtr\[]]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): The managed array to convert.**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): The class of the array's elements.

### Returns

| Type                                                           | Description                                                      |
| -------------------------------------------------------------- | ---------------------------------------------------------------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) | A local reference to the newly constructed Java array of object. |

### Remarks

Additional Resources: [AndroidJNI.NewObjectArray](/engine/7000.0/script-reference/unityengine/androidjni/newobjectarray.md), [AndroidJNI.SetObjectArrayElement](/engine/7000.0/script-reference/unityengine/androidjni/setobjectarrayelement.md)

## ToObjectArray(IntPtr\[])

Converts a managed array of System.IntPtr, representing Java objects, to a Java array of \\\<tt\\>java.lang.Object\\\</tt\\>.

```csharp
public static nint ToObjectArray(nint[] array)
```

### Parameters

**** (\[IntPtr\[]]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): The managed array to convert.

### Returns

| Type                                                           | Description                                                      |
| -------------------------------------------------------------- | ---------------------------------------------------------------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) | A local reference to the newly constructed Java array of object. |

### Remarks

Additional Resources: [AndroidJNI.NewObjectArray](/engine/7000.0/script-reference/unityengine/androidjni/newobjectarray.md), [AndroidJNI.SetObjectArrayElement](/engine/7000.0/script-reference/unityengine/androidjni/setobjectarrayelement.md)
