# FixedString512Bytes

> An unmanaged UTF-8 string whose content is stored directly in the 512-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 FixedString512Bytes : 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 512 (two length bytes and one null byte).

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

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

## Properties

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

## Static Properties

| Property                                                                                                              | Description                                                                  |
| --------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [UTF8MaxLengthInBytes](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/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/fixedstring512bytes/add.md)                     | Appends a byte.                                                                      |
| [AsFixedList](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/asfixedlist.md)     | Returns a reference to a FixedList512Bytes\\\<byte\\> representation of this string. |
| [Clear](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/clear.md)                 | Sets the length to 0.                                                                |
| [CompareTo](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/compareto.md)         | Returns the lexicographical sort order of this string relative to another.           |
| [ElementAt](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/elementat.md)         | Returns the reference to a byte (not character) at an index.                         |
| [Equals](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/equals.md)               | Returns true if this string and an object are equal.                                 |
| [GetEnumerator](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/getenumerator.md) | Returns an enumerator for iterating over the characters of this string.              |
| [GetHashCode](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/gethashcode.md)     | Returns a hash code of this string.                                                  |
| [GetUnsafePtr](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/getunsafeptr.md)   | Returns a pointer to the character bytes.                                            |
| [ToString](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/tostring.md)           | Returns a new managed string that is a copy of this string.                          |
| [TryResize](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/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/fixedstring512bytes/op-equality.md)          | Returns true if a FixedString512Bytes and another string are equal.   |
| [FixedString512Bytes](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/op-implicit.md)  | Returns a new FixedString512Bytes that is a copy of another string.   |
| [FixedString4096Bytes](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/op-implicit.md) | Returns a new FixedString4096Bytes that is a copy of another string.  |
| [operator !=](/engine/6000.7/script-reference/unity/collections/fixedstring512bytes/op-inequality.md)        | Returns true if a FixedString512Bytes and another string are unequal. |

## Structs

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