> For the complete documentation index, see [llms.txt](https://docs.yarnspinner.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yarnspinner.dev/3.1/api/csharp/yarn.saliency/yarn.saliency.enumerablerandomextension/yarn.saliency.enumerablerandomextension.randomelement.md).

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

Method in [EnumerableRandomExtension](/3.1/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` .
