> For the complete documentation index, see [llms.txt](https://xplat.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xplat.gitbook.io/docs/xplat.core/collectionextensions.md).

# CollectionExtensions

> Namespace: XPlat.Extensions

Defines a collection of extensions for enumerable objects.

```csharp
public static class CollectionExtensions
```

## Supported platforms

| Platform        | Version    |
| --------------- | ---------- |
| .NET Standard   | 2.0        |
| Xamarin.Android | 9.0        |
| Xamarin.iOS     | 1.0        |
| UWP             | 10.0.16299 |

## Static Methods

### Take(this List, int, int)

Takes a number of elements from the specified list from the specified starting index.

```csharp
public static IEnumerable<T> Take<T>(this List<T> list, int startingIndex, int takeCount)
```

#### Parameters

**list (List)**

The list to take items from.

**startingIndex (int)**

The index to start at in the list.

**takeCount (int)**

The number of items to take from the starting index of the list.

#### Returns

Returns a collection of T items.

### Take(this IReadOnlyList, int, int)

Takes a number of elements from the specified readonly list from the specified starting index.

```csharp
public static IEnumerable<T> Take<T>(this IReadOnlyList<T> list, int startingIndex, int takeCount)
```

#### Example

This example shows how the Take method can be used to take a range of items from a collection.

```csharp
IReadOnlyList<IStorageItem> items = await this.GetItemsAsync();

/// Gets the 5th to 10th items.
List<IStorageItem> specificItems = items.Take(5, 10).ToList();
```

#### Parameters

**list (List)**

The list to take items from.

**startingIndex (int)**

The index to start at in the list.

**takeCount (int)**

The number of items to take from the starting index of the list.

#### Returns

Returns a collection of T items.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xplat.gitbook.io/docs/xplat.core/collectionextensions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
