Skip to main content

ListExtensions


Namespace: FivePD.API.Utils#
File: Source/Utils/ListExtensions.cs#

List extensions#

SelectRandom<T>#

public static T SelectRandom<T>(this IEnumerable<T> enumerable);

Selects a random element from the given list.

Params:

  • enumerable
    • Type: IEnumerable<T>
    • Collection - random result will be selected from this list
public static T SelectRandom<T>(this IEnumerable<T> enumerable, IEnumerable<T> exclusions);

Excludes the given elements (won't be selected).

Params:

  • enumerable
    • Type: IEnumerable<T>
    • Collection - random result will be selected from this list
  • exclusions
    • Type: IEnumerable<T>
    • Collection - the random result can't be any of these