# NativeReference<T>

> An unmanaged single value.

## 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), [IEquatable\<NativeReference\<T>>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public struct NativeReference<T> : INativeDisposable, IDisposable, IEquatable<NativeReference<T>> where T : unmanaged
```

## Remarks

The functional equivalent of an array of length 1. When you need just one value, NativeReference can be preferable to an array because it better conveys the intent.

## Constructors

| Constructor                                                                                                                                                                                                                                     | Description                                             |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| [NativeReference\`1(\`0,Unity.Collections.AllocatorManager.AllocatorHandle)](/engine/6000.7/script-reference/unity/collections/nativereference1/ctor.md#nativereference\(t-allocatorhandle\))                                                   | Initializes and returns an instance of NativeReference. |
| [NativeReference\`1(Unity.Collections.AllocatorManager.AllocatorHandle,Unity.Collections.NativeArrayOptions)](/engine/6000.7/script-reference/unity/collections/nativereference1/ctor.md#nativereference\(allocatorhandle-nativearrayoptions\)) | Initializes and returns an instance of NativeReference. |

## Properties

| Property                                                                                     | Description                                                          |
| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| [IsCreated](/engine/6000.7/script-reference/unity/collections/nativereference1/iscreated.md) | Whether this reference has been allocated (and not yet deallocated). |
| [Value](/engine/6000.7/script-reference/unity/collections/nativereference1/value.md)         | The value stored in this reference.                                  |

## Methods

| Method                                                                                           | Description                                                               |
| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
| [AsReadOnly](/engine/6000.7/script-reference/unity/collections/nativereference1/asreadonly.md)   | Returns a read-only reference aliasing the value of this reference.       |
| [CopyFrom](/engine/6000.7/script-reference/unity/collections/nativereference1/copyfrom.md)       | Copy the value of another reference to this reference.                    |
| [CopyTo](/engine/6000.7/script-reference/unity/collections/nativereference1/copyto.md)           | Copy the value of this reference to another reference.                    |
| [Dispose](/engine/6000.7/script-reference/unity/collections/nativereference1/dispose.md)         | Releases all resources (memory and safety handles).                       |
| [Equals](/engine/6000.7/script-reference/unity/collections/nativereference1/equals.md)           | Returns true if the value stored in this reference is equal to an object. |
| [GetHashCode](/engine/6000.7/script-reference/unity/collections/nativereference1/gethashcode.md) | Returns the hash code of this reference.                                  |

## Static Methods

| Method                                                                             | Description                                           |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------- |
| [Copy](/engine/6000.7/script-reference/unity/collections/nativereference1/copy.md) | Copies the value of a reference to another reference. |

## Operators

| Operator                                                                                           | Description                                                                          |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| [operator ==](/engine/6000.7/script-reference/unity/collections/nativereference1/op-equality.md)   | Returns true if the values stored in two references are equal.                       |
| [ReadOnly](/engine/6000.7/script-reference/unity/collections/nativereference1/op-implicit.md)      | Returns a read-only native reference that aliases the content of a native reference. |
| [operator !=](/engine/6000.7/script-reference/unity/collections/nativereference1/op-inequality.md) | Returns true if the values stored in two references are unequal.                     |

## Structs

| Struct                                                                                                         | Description                                                                                    |
| -------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| [NativeReference\<T>.ReadOnly](/engine/6000.7/script-reference/unity/collections/nativereference1/readonly.md) | A read-only alias for the value of a NativeReference. Does not have its own allocated storage. |
