# NativeList<T>

> An unmanaged, resizable list.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule
* **Implements:** [INativeDisposable](/engine/6000.7/script-reference/unity/collections/inativedisposable.md), [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable), [INativeList\<T>](/engine/6000.7/script-reference/unity/collections/inativelist1.md), [IIndexable\<T>](/engine/6000.7/script-reference/unity/collections/iindexable1.md), [IEnumerable\<T>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable)

```csharp
public struct NativeList<T> : INativeDisposable, IDisposable, INativeList<T>, IIndexable<T>, IEnumerable<T>, IEnumerable where T : unmanaged
```

## Remarks

The elements are stored contiguously in a buffer rather than as linked nodes.

## Static Fields

| Value                                                                                       | Description                                                     |
| ------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [MaxCapacity](/engine/6000.7/script-reference/unity/collections/nativelist1/maxcapacity.md) | The maximum number of elements this type of container can hold. |

## Constructors

| Constructor                                                                                                                                                                               | Description                                                  |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| [NativeList\`1(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle)](/engine/6000.7/script-reference/unity/collections/nativelist1/ctor.md#nativelist\(int-allocatorhandle\)) | Initializes and returns a NativeList.                        |
| [NativeList\`1(Unity.Collections.AllocatorManager.AllocatorHandle)](/engine/6000.7/script-reference/unity/collections/nativelist1/ctor.md#nativelist\(allocatorhandle\))                  | Initializes and returns a NativeList with a capacity of one. |

## Properties

| Property                                                                                | Description                                                     |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [Capacity](/engine/6000.7/script-reference/unity/collections/nativelist1/capacity.md)   | The number of elements that fit in the current allocation.      |
| [IsCreated](/engine/6000.7/script-reference/unity/collections/nativelist1/iscreated.md) | Whether this list has been allocated (and not yet deallocated). |
| [IsEmpty](/engine/6000.7/script-reference/unity/collections/nativelist1/isempty.md)     | Whether this list is empty.                                     |
| [this\[\]](/engine/6000.7/script-reference/unity/collections/nativelist1/item.md)       | The element at a given index.                                   |
| [Length](/engine/6000.7/script-reference/unity/collections/nativelist1/length.md)       | The count of elements.                                          |

## Methods

| Method                                                                                                              | Description                                                                                                                          |
| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| [Add](/engine/6000.7/script-reference/unity/collections/nativelist1/add.md)                                         | Appends an element to the end of this list.                                                                                          |
| [AddNoResize](/engine/6000.7/script-reference/unity/collections/nativelist1/addnoresize.md)                         | Appends an element to the end of this list.                                                                                          |
| [AddRange](/engine/6000.7/script-reference/unity/collections/nativelist1/addrange.md)                               | Copies elements from a ReadOnlySpan to the end of this list.                                                                         |
| [AddRangeNoResize](/engine/6000.7/script-reference/unity/collections/nativelist1/addrangenoresize.md)               | Copies elements from a ReadOnlySpan to the end of this list.                                                                         |
| [AddReplicate](/engine/6000.7/script-reference/unity/collections/nativelist1/addreplicate.md)                       | Appends value count times to the end of this list.                                                                                   |
| [AsArray](/engine/6000.7/script-reference/unity/collections/nativelist1/asarray.md)                                 | Returns a native array that aliases the content of this list.                                                                        |
| [AsDeferredJobArray](/engine/6000.7/script-reference/unity/collections/nativelist1/asdeferredjobarray.md)           | Returns an array that aliases this list. The length of the array is updated when the length of this array is updated in a prior job. |
| [AsParallelReader](/engine/6000.7/script-reference/unity/collections/nativelist1/asparallelreader.md)               | Returns a parallel reader of this list.                                                                                              |
| [AsParallelWriter](/engine/6000.7/script-reference/unity/collections/nativelist1/asparallelwriter.md)               | Returns a parallel writer of this list.                                                                                              |
| [AsReadOnly](/engine/6000.7/script-reference/unity/collections/nativelist1/asreadonly.md)                           | Returns a read only of this list.                                                                                                    |
| [AsReadOnlySpan](/engine/6000.7/script-reference/unity/collections/nativelist1/asreadonlyspan.md)                   | Returns ReadOnlySpan\\\<T\\> view of this container.                                                                                 |
| [AsSpan](/engine/6000.7/script-reference/unity/collections/nativelist1/asspan.md)                                   | Returns Span\\\<T\\> view of this container.                                                                                         |
| [Clear](/engine/6000.7/script-reference/unity/collections/nativelist1/clear.md)                                     | Sets the length to 0.                                                                                                                |
| [CopyFrom](/engine/6000.7/script-reference/unity/collections/nativelist1/copyfrom.md)                               | Copies all elements of specified container to this container.                                                                        |
| [Dispose](/engine/6000.7/script-reference/unity/collections/nativelist1/dispose.md)                                 | Releases all resources (memory and safety handles).                                                                                  |
| [ElementAt](/engine/6000.7/script-reference/unity/collections/nativelist1/elementat.md)                             | Returns a reference to the element at an index.                                                                                      |
| [GetEnumerator](/engine/6000.7/script-reference/unity/collections/nativelist1/getenumerator.md)                     | Returns an enumerator over the elements of this list.                                                                                |
| [GetUnsafeList](/engine/6000.7/script-reference/unity/collections/nativelist1/getunsafelist.md)                     | Returns the internal unsafe list.                                                                                                    |
| [GetUnsafePtr](/engine/6000.7/script-reference/unity/collections/nativelist1/getunsafeptr.md)                       | Get a pointer to the data.                                                                                                           |
| [GetUnsafeReadOnlyPtr](/engine/6000.7/script-reference/unity/collections/nativelist1/getunsafereadonlyptr.md)       | Get a pointer to the data.                                                                                                           |
| [InsertRange](/engine/6000.7/script-reference/unity/collections/nativelist1/insertrange.md)                         | Shifts elements toward the end of this list, increasing its length.                                                                  |
| [InsertRangeWithBeginEnd](/engine/6000.7/script-reference/unity/collections/nativelist1/insertrangewithbeginend.md) | Shifts elements toward the end of this list, increasing its length.                                                                  |
| [RemoveAt](/engine/6000.7/script-reference/unity/collections/nativelist1/removeat.md)                               | Removes the element at an index, shifting everything above it down by one. Decrements the length by 1.                               |
| [RemoveAtSwapBack](/engine/6000.7/script-reference/unity/collections/nativelist1/removeatswapback.md)               | Copies the last element of this list to the specified index. Decrements the length by 1.                                             |
| [RemoveRange](/engine/6000.7/script-reference/unity/collections/nativelist1/removerange.md)                         | Removes "N" elements in a range, shifting everything above the range down by "N". Decrements the length by "N".                      |
| [RemoveRangeSwapBack](/engine/6000.7/script-reference/unity/collections/nativelist1/removerangeswapback.md)         | Copies the last "N" elements of this list to a range in this list. Decrements the length by "N".                                     |
| [Resize](/engine/6000.7/script-reference/unity/collections/nativelist1/resize.md)                                   | Sets the length of this list, increasing the capacity if necessary.                                                                  |
| [ResizeUninitialized](/engine/6000.7/script-reference/unity/collections/nativelist1/resizeuninitialized.md)         | Sets the length of this list, increasing the capacity if necessary.                                                                  |
| [SetCapacity](/engine/6000.7/script-reference/unity/collections/nativelist1/setcapacity.md)                         | Sets the capacity.                                                                                                                   |
| [ToArray](/engine/6000.7/script-reference/unity/collections/nativelist1/toarray.md)                                 | Returns an array containing a copy of this list's content.                                                                           |
| [TrimExcess](/engine/6000.7/script-reference/unity/collections/nativelist1/trimexcess.md)                           | Sets the capacity to match the length.                                                                                               |

## Structs

| Struct                                                                                                           | Description                         |
| ---------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| [NativeList\<T>.ParallelWriter](/engine/6000.7/script-reference/unity/collections/nativelist1/parallelwriter.md) | A parallel writer for a NativeList. |
