Class ReadOnlyList<T>
Wraps a List<T> to provide a read-only view of its memory without copying any elements.
It is preferable to use this collection in API designs instead of IReadOnlyCollection because
GetEnumerator() returns a value-type enumerator and does not perform any heap allocations.
Inherited Members
Namespace: Unity.XR.CoreUtils.Collections
Assembly: Unity.XR.CoreUtils.dll
Syntax
public class ReadOnlyList<T> : IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
| Name | Description |
|---|---|
| T | The element type. |
Remarks
This collection is not thread-safe.
Constructors
ReadOnlyList(List<T>)
Constructs a new instance of this class that is a read-only wrapper around the specified list.
Declaration
public ReadOnlyList(List<T> list)
Parameters
| Type | Name | Description |
|---|---|---|
| List<T> | list | The list to wrap. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
Properties
Count
The number of elements in the list.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int | The number of elements. |
this[int]
Returns the element at index.
Declaration
public T this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index. |
Property Value
| Type | Description |
|---|---|
| T |
Methods
GetEnumerator()
Returns an enumerator that iterates through the list.
Declaration
public List<T>.Enumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| List<T>.Enumerator | The enumerator. |