# TryResize(int, NativeArrayOptions)

> Attempts to set the length in bytes. Does nothing if the new length is invalid.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule

```csharp
public bool TryResize(int newLength, NativeArrayOptions clearOptions = NativeArrayOptions.ClearMemory)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The desired length.**** (\[NativeArrayOptions]\(/engine/6000.7/script-reference/unity/collections/nativearrayoptions)): Whether added or removed bytes should be cleared (zeroed). (Increasing the length adds bytes; decreasing the length removes bytes.)

### Returns

| Type                                                          | Description                      |
| ------------------------------------------------------------- | -------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the new length is valid. |
