Show / Hide Table of Contents

Class CollectionExtensions

General extensions for collections

Inheritance
System.Object
CollectionExtensions
Namespace: HarmonyLib
Assembly: 0Harmony.dll
Syntax
public static class CollectionExtensions

Methods

| Improve this Doc View Source

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

A helper to add an item to a collection

Declaration
public static IEnumerable<T> AddItem<T>(this IEnumerable<T> sequence, T item)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> sequence

The collection

T item

The item to add

Returns
Type Description
System.Collections.Generic.IEnumerable<T>

The collection containing the item

Type Parameters
Name Description
T

The inner type of the collection

| Improve this Doc View Source

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

A helper to add items to an array

Declaration
public static T[] AddRangeToArray<T>(this T[] sequence, T[] items)
Parameters
Type Name Description
T[] sequence

The array

T[] items

The items to add

Returns
Type Description
T[]

The array containing the items

Type Parameters
Name Description
T

The inner type of the collection

| Improve this Doc View Source

AddToArray<T>(T[], T)

A helper to add an item to an array

Declaration
public static T[] AddToArray<T>(this T[] sequence, T item)
Parameters
Type Name Description
T[] sequence

The array

T item

The item to add

Returns
Type Description
T[]

The array containing the item

Type Parameters
Name Description
T

The inner type of the collection

| Improve this Doc View Source

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

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

Declaration
public static void Do<T>(this IEnumerable<T> sequence, Action<T> action)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> sequence

The collection

System.Action<T> action

The action to execute

Type Parameters
Name Description
T

The inner type of the collection

| Improve this Doc View Source

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

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

Declaration
public static void DoIf<T>(this IEnumerable<T> sequence, Func<T, bool> condition, Action<T> action)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> sequence

The collection

System.Func<T, System.Boolean> condition

The predicate

System.Action<T> action

The action to execute

Type Parameters
Name Description
T

The inner type of the collection

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX