# RandomElement\<T>(IEnumerable\<T>)

Method in [EnumerableRandomExtension](/api/csharp/yarn.saliency/yarn.saliency.enumerablerandomextension.md)

## Summary

Returns a random element from `enumerable` .

```csharp
public static T RandomElement<T>(this IEnumerable<T> enumerable)
```

## Remarks

This method uses System.Random to make a selection, which is cryptographically insecure. This means that this method should not be used for security-critical decisions.

## Parameters

| Name                                                   | Description                            |
| ------------------------------------------------------ | -------------------------------------- |
| `System.Collections.Generic.IEnumerable<T>` enumerable | The collection to choose an item from. |

## Type Parameters

| Name | Description                           |
| ---- | ------------------------------------- |
| T    | The type of element in `enumerable` . |

## Returns

A random element in `enumerable` .


---

# Agent Instructions: 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://docs.yarnspinner.dev/api/csharp/yarn.saliency/yarn.saliency.enumerablerandomextension/yarn.saliency.enumerablerandomextension.randomelement.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.
