Browse documentation

Class CollectionExtensions

Namespace
HarmonyLib
Assembly
0Harmony.dll

General extensions for collections

public static class CollectionExtensions
Inheritance
object
CollectionExtensions

Methods

AddItem<T>(IEnumerable<T>, T)

A helper to add an item to a collection

public static IEnumerable<T> AddItem<T>(this IEnumerable<T> sequence, T item)

Parameters

sequence IEnumerable<T>

The collection

item T

The item to add

Returns

IEnumerable<T>

The collection containing the item

Type Parameters

T

The inner type of the collection

AddRangeToArray<T>(T[], T[])

A helper to add items to an array

public static T[] AddRangeToArray<T>(this T[] sequence, T[] items)

Parameters

sequence T[]

The array

items T[]

The items to add

Returns

T[]

The array containing the items

Type Parameters

T

The inner type of the collection

AddToArray<T>(T[], T)

A helper to add an item to an array

public static T[] AddToArray<T>(this T[] sequence, T item)

Parameters

sequence T[]

The array

item T

The item to add

Returns

T[]

The array containing the item

Type Parameters

T

The inner type of the collection

DoIf<T>(IEnumerable<T>, Func<T, bool>, Action<T>)

A simple way to execute code for elements in a collection matching a condition

public static void DoIf<T>(this IEnumerable<T> sequence, Func<T, bool> condition, Action<T> action)

Parameters

sequence IEnumerable<T>

The collection

condition Func<T, bool>

The predicate

action Action<T>

The action to execute

Type Parameters

T

The inner type of the collection

Do<T>(IEnumerable<T>, Action<T>)

A simple way to execute code for every element in a collection

public static void Do<T>(this IEnumerable<T> sequence, Action<T> action)

Parameters

sequence IEnumerable<T>

The collection

action Action<T>

The action to execute

Type Parameters

T

The inner type of the collection

Harmony 3 preview

For the stable release, read the 2.x documentation.