# FixedString32Bytes

> An unmanaged UTF-8 string whose content is stored directly in the 32-byte struct.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule
* **Implements:** [INativeList\<byte>](/engine/6000.7/script-reference/unity/collections/inativelist1.md), [IIndexable\<byte>](/engine/6000.7/script-reference/unity/collections/iindexable1.md), [IUTF8Bytes](/engine/6000.7/script-reference/unity/collections/iutf8bytes.md), [IComparable\<string>](https://learn.microsoft.com/dotnet/api/system.icomparable-1), [IEquatable\<string>](https://learn.microsoft.com/dotnet/api/system.iequatable-1), [IComparable\<FixedString32Bytes>](https://learn.microsoft.com/dotnet/api/system.icomparable-1), [IEquatable\<FixedString32Bytes>](https://learn.microsoft.com/dotnet/api/system.iequatable-1), [IComparable\<FixedString64Bytes>](https://learn.microsoft.com/dotnet/api/system.icomparable-1), [IEquatable\<FixedString64Bytes>](https://learn.microsoft.com/dotnet/api/system.iequatable-1), [IComparable\<FixedString128Bytes>](https://learn.microsoft.com/dotnet/api/system.icomparable-1), [IEquatable\<FixedString128Bytes>](https://learn.microsoft.com/dotnet/api/system.iequatable-1), [IComparable\<FixedString512Bytes>](https://learn.microsoft.com/dotnet/api/system.icomparable-1), [IEquatable\<FixedString512Bytes>](https://learn.microsoft.com/dotnet/api/system.iequatable-1), [IComparable\<FixedString4096Bytes>](https://learn.microsoft.com/dotnet/api/system.icomparable-1), [IEquatable\<FixedString4096Bytes>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public struct FixedString32Bytes : INativeList<byte>, IIndexable<byte>, IUTF8Bytes, IComparable<string>, IEquatable<string>, IComparable<FixedString32Bytes>, IEquatable<FixedString32Bytes>, IComparable<FixedString64Bytes>, IEquatable<FixedString64Bytes>, IComparable<FixedString128Bytes>, IEquatable<FixedString128Bytes>, IComparable<FixedString512Bytes>, IEquatable<FixedString512Bytes>, IComparable<FixedString4096Bytes>, IEquatable<FixedString4096Bytes>
```

## Remarks

The binary layout of this string is guaranteed, for now and all time, to be a length (a little-endian two byte integer) followed by the bytes of the characters (with no padding). A zero byte always immediately follows the last character. Effectively, the number of bytes for storing characters is 3 less than 32 (two length bytes and one null byte).

This layout is identical to a [FixedList32Bytes\<T>](/engine/6000.7/script-reference/unity/collections/fixedlist32bytes1.md) of bytes, thus allowing reinterpretation between FixedString32Bytes and FixedList32Bytes.

By virtue of being an unmanaged, non-allocated struct with no pointers, this string is fully compatible with jobs and Burst compilation. Unlike managed string types, these strings can be put in any unmanaged ECS components, FixedList, or any other unmanaged structs.

## Constructors

| Constructor                                                                                                                                                                            | Description                                                                                                                 |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| [FixedString32Bytes(System.String)](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/ctor.md#fixedstring32bytes\(string\))                                         | Initializes and returns an instance of FixedString32Bytes with the characters copied from a string.                         |
| [FixedString32Bytes(Unity.Collections.FixedString128Bytes@)](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/ctor.md#fixedstring32bytes\(fixedstring128bytes\))   | Initializes and returns an instance of FixedString32Bytes that is a copy of another string.                                 |
| [FixedString32Bytes(Unity.Collections.FixedString32Bytes@)](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/ctor.md#fixedstring32bytes\(fixedstring32bytes\))     | Initializes and returns an instance of FixedString32Bytes that is a copy of another string.                                 |
| [FixedString32Bytes(Unity.Collections.FixedString4096Bytes@)](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/ctor.md#fixedstring32bytes\(fixedstring4096bytes\)) | Initializes and returns an instance of FixedString32Bytes that is a copy of another string.                                 |
| [FixedString32Bytes(Unity.Collections.FixedString512Bytes@)](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/ctor.md#fixedstring32bytes\(fixedstring512bytes\))   | Initializes and returns an instance of FixedString32Bytes that is a copy of another string.                                 |
| [FixedString32Bytes(Unity.Collections.FixedString64Bytes@)](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/ctor.md#fixedstring32bytes\(fixedstring64bytes\))     | Initializes and returns an instance of FixedString32Bytes that is a copy of another string.                                 |
| [FixedString32Bytes(Unity.Collections.LowLevel.Unsafe.UnsafeText@)](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/ctor.md#fixedstring32bytes\(unsafetext\))     | Initializes and returns an instance of FixedString32Bytes that is a copy of another string.                                 |
| [FixedString32Bytes(Unity.Collections.NativeText.ReadOnly)](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/ctor.md#fixedstring32bytes\(readonly\))               | Initializes and returns an instance of FixedString32Bytes with the characters copied from a string.                         |
| [FixedString32Bytes(Unity.Collections.Unicode.Rune,System.Int32)](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/ctor.md#fixedstring32bytes\(rune-int\))         | Initializes and returns an instance of FixedString32Bytes with a single character repeatedly appended some number of times. |

## Properties

| Property                                                                                     | Description                                                                                                                                         |
| -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Capacity](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/capacity.md) | The number of bytes this string has for storing UTF-8 characters.                                                                                   |
| [IsEmpty](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/isempty.md)   | Returns true if this string is empty (has no characters).                                                                                           |
| [this\[\]](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/item.md)     | Returns the byte (not character) at an index.                                                                                                       |
| [Length](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/length.md)     | The current length in bytes of this string's content.                                                                                               |
| [Value](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/value.md)       | For internal use only. Use [FixedString32Bytes.ToString](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/tostring.md) instead. |

## Static Properties

| Property                                                                                                             | Description                                                                  |
| -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [UTF8MaxLengthInBytes](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/utf8maxlengthinbytes.md) | Returns the maximum number of UTF-8 bytes that can be stored in this string. |

## Methods

| Method                                                                                                 | Description                                                                         |
| ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- |
| [Add](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/add.md)                     | Appends a byte.                                                                     |
| [AsFixedList](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/asfixedlist.md)     | Returns a reference to a FixedList32Bytes\\\<byte\\> representation of this string. |
| [Clear](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/clear.md)                 | Sets the length to 0.                                                               |
| [CompareTo](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/compareto.md)         | Returns the lexicographical sort order of this string relative to another.          |
| [ElementAt](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/elementat.md)         | Returns the reference to a byte (not character) at an index.                        |
| [Equals](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/equals.md)               | Returns true if this string and an object are equal.                                |
| [GetEnumerator](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/getenumerator.md) | Returns an enumerator for iterating over the characters of this string.             |
| [GetHashCode](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/gethashcode.md)     | Returns a hash code of this string.                                                 |
| [GetUnsafePtr](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/getunsafeptr.md)   | Returns a pointer to the character bytes.                                           |
| [ToString](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/tostring.md)           | Returns a new managed string that is a copy of this string.                         |
| [TryResize](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/tryresize.md)         | Attempts to set the length in bytes. Does nothing if the new length is invalid.     |

## Operators

| Operator                                                                                                    | Description                                                          |
| ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| [operator ==](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/op-equality.md)          | Returns true if a FixedString32Bytes and another string are equal.   |
| [FixedString32Bytes](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/op-implicit.md)   | Returns a new FixedString32Bytes that is a copy of another string.   |
| [FixedString128Bytes](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/op-implicit.md)  | Returns a new FixedString128Bytes that is a copy of another string.  |
| [FixedString4096Bytes](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/op-implicit.md) | Returns a new FixedString4096Bytes that is a copy of another string. |
| [FixedString512Bytes](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/op-implicit.md)  | Returns a new FixedString512Bytes that is a copy of another string.  |
| [FixedString64Bytes](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/op-implicit.md)   | Returns a new FixedString64Bytes that is a copy of another string.   |
| [operator !=](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/op-inequality.md)        | Returns true if a FixedString32Bytes and another string are unequal. |

## Structs

| Struct                                                                                                              | Description                                                            |
| ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| [FixedString32Bytes.Enumerator](/engine/6000.7/script-reference/unity/collections/fixedstring32bytes/enumerator.md) | An enumerator over the characters (not bytes) of a FixedString32Bytes. |
