# GenericEnumerable<T>

Kind: Class · Namespace: Sansar.Utility · Assembly: Sansar.Script.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-class" data-pagefind-filter="kind:Class">Class</span>
<span data-pagefind-filter="namespace:Sansar.Utility">Namespace <a href="/scripting/api/sansar.utility"><code>Sansar.Utility</code></a></span>
<span>Inherits <a href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable&lt;T&gt;</a></span>
</div>

<span id="T:Sansar.Utility.GenericEnumerable`1"></span>

The GenericEnumerable takes a delegate which accesses items in a Array-like collection by index and allows iteration through enumeration.

```csharp
public class GenericEnumerable<T> : IEnumerable<T> where T : class
```

**Type parameters:** `T`: The type of objects returned by [`GenericEnumerable<T>.GetItem`](/scripting/api/sansar.utility/genericenumerable-1.getitem)

## Remarks

This is used by some API methods to allow for enumerations on some colletions.

## Members at a glance

| Kind | Members |
|---|---|
| **Constructors** | [GenericEnumerable](#genericenumerable) |
| **Properties** | [Count](#count) |
| **Methods** | [GetEnumerator](#getenumerator) · [System\#Collections\#IEnumerable\#GetEnumerator](#systemcollectionsienumerablegetenumerator) |

## Constructors

### GenericEnumerable

<div class="api-card">
<span id="M:Sansar.Utility.GenericEnumerable`1.#ctor(System.UInt32,Sansar.Utility.GenericEnumerable{`0}.GetItem)"></span>
<span id="C:Sansar.Utility.GenericEnumerable`1(System.UInt32,Sansar.Utility.GenericEnumerable{`0}.GetItem)"></span>

```csharp signature
public GenericEnumerable(
    uint count,
    GenericEnumerable<T>.GetItem getItem
)
```

Initializes the enumerable with an item count and an accessor delegate.

| Parameter | Type | Description |
|---|---|---|
| `count` | [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | Total number of items in the collection. |
| `getItem` | [GenericEnumerable&lt;T&gt;.GetItem](/scripting/api/sansar.utility/genericenumerable-1.getitem) | Delegate which retrieves an item from a collection by index. |

<details class="api-remarks"><summary>Remarks</summary>

If the item count changes or items change index the enumeration may be invalidated.

</details>

</div>


## Properties

### Count

<div class="api-card">
<span id="P:Sansar.Utility.GenericEnumerable`1.Count"></span>

```csharp signature
public uint Count { get; }
```

The total number of items in the collection.

**Value:** [uint](https://learn.microsoft.com/dotnet/api/system.uint32) — The total number of items in the collection.

<details class="api-remarks"><summary>Remarks</summary>

Set by the constructor.

</details>

</div>


## Methods

### GetEnumerator

<div class="api-card">
<span id="M:Sansar.Utility.GenericEnumerable`1.GetEnumerator"></span>
<span id="M:Sansar.Utility.GenericEnumerable`1.GetEnumerator()"></span>

```csharp signature
public IEnumerator<T> GetEnumerator()
```

Returns an enumerator that iterates through the collection.

**Returns:** [IEnumerator&lt;T&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerator-1) — An enumerator that can be used to iterate through the collection.

<details class="api-remarks"><summary>Remarks</summary>

If the item count changes or items change index the enumeration may be invalidated.

</details>

</div>

### System\#Collections\#IEnumerable\#GetEnumerator

<div class="api-card">
<span id="M:Sansar.Utility.GenericEnumerable`1.System#Collections#IEnumerable#GetEnumerator"></span>
<span id="M:Sansar.Utility.GenericEnumerable`1.System#Collections#IEnumerable#GetEnumerator()"></span>

```csharp signature
IEnumerator System.Collections.IEnumerable.GetEnumerator()
```

Returns an enumerator that iterates through the collection.

**Returns:** [IEnumerator](https://learn.microsoft.com/dotnet/api/system.collections.ienumerator) — An enumerator that can be used to iterate through the collection.

<details class="api-remarks"><summary>Remarks</summary>

If the item count changes or items change index the enumeration may be invalidated.

</details>

</div>




<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>