Show / Hide Table of Contents

Class Utility

Static class containing extension helper methods for various built-in C# classes, as well as a static helper method for "swapping" references.

Inheritance
object
Utility
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
public static class Utility

Methods

View Source

AsReadOnly<TKey, TValue>(IDictionary<TKey, TValue>)

Adds an AsReadOnly method to IDictionary<TKey, TValue>, similar to the AsReadOnly method of IList<T>, that returns a read-only reference to the dictionary.

Declaration
public static ReadOnlyDictionary<TKey, TValue> AsReadOnly<TKey, TValue>(this IDictionary<TKey, TValue> dictionary) where TKey : notnull
Parameters
Type Name Description
IDictionary<TKey, TValue> dictionary
Returns
Type Description
ReadOnlyDictionary<TKey, TValue>

A ReadOnlyDictionary instance for the specified dictionary.

Type Parameters
Name Description
TKey

Type of keys of the dictionary.

TValue

Type of values of the dictionary.

View Source

Flatten<T>(params IEnumerable<T>[])

Takes multiple enumerables of items, and flattens them into a single IEnumerable.

Declaration
public static IEnumerable<T> Flatten<T>(params IEnumerable<T>[] lists)
Parameters
Type Name Description
IEnumerable<T>[] lists

Lists to "flatten".

Returns
Type Description
IEnumerable<T>

An IEnumerable containing the items of all the enumerables passed in.

Type Parameters
Name Description
T
View Source

Multiply(string, int)

"Multiplies", aka repeats, a string the given number of times.

Declaration
public static string Multiply(this string str, int numTimes)
Parameters
Type Name Description
string str
int numTimes

The number of times to repeat the string.

Returns
Type Description
string

The current string repeated numTimes times.

View Source

Swap<T>(ref T, ref T)

Swaps the values pointed to by lhs and rhs.

Declaration
public static void Swap<T>(ref T lhs, ref T rhs)
Parameters
Type Name Description
T lhs
T rhs
Type Parameters
Name Description
T
View Source

Yield<T>(T)

Convenience function that yields the given item as a single-item IEnumerable.

Declaration
public static IEnumerable<T> Yield<T>(this T item)
Parameters
Type Name Description
T item
Returns
Type Description
IEnumerable<T>

An IEnumerable containing only the item the function is called on.

Type Parameters
Name Description
T
View Source

Yield<T>(params T[])

Takes multiple parameters and converts them to an IEnumerable.

Declaration
public static IEnumerable<T> Yield<T>(params T[] values)
Parameters
Type Name Description
T[] values

Parameters (specified as multiple parameters to the function).

Returns
Type Description
IEnumerable<T>

An IEnumerable of all of the given items, in the order they were given to the function.

Type Parameters
Name Description
T
  • View Source
In this article
Back to top Generated by DocFX