Table of Contents

Class Extensions

Namespace
DisCatSharp.Common
Assembly
DisCatSharp.Common.dll

Assortment of various extension and utility methods, designed to make working with various types a little easier.

public static class Extensions
Inheritance
Extensions
Inherited Members

Methods

Base64Decode(string)

Decodes a base64 string.

Base64Encode(string)

Encodes a string to base64.

CalculateKnuthHash(ArraySegment<char>)

Computes a 64-bit Knuth hash from supplied characters.

CalculateKnuthHash(char[])

Computes a 64-bit Knuth hash from supplied characters.

CalculateKnuthHash(char[], int, int)

Computes a 64-bit Knuth hash from supplied characters.

CalculateKnuthHash(Memory<char>)

Computes a 64-bit Knuth hash from supplied characters.

CalculateKnuthHash(ReadOnlyMemory<char>)

Computes a 64-bit Knuth hash from supplied characters.

CalculateKnuthHash(ReadOnlySpan<char>)

Computes a 64-bit Knuth hash from supplied characters.

CalculateKnuthHash(Span<char>)

Computes a 64-bit Knuth hash from supplied characters.

CalculateKnuthHash(string)

Computes a 64-bit Knuth hash from supplied characters.

CalculateKnuthHash(string, int, int)

Computes a 64-bit Knuth hash from supplied characters.

CalculateLength(byte)

Calculates the length of string representation of given number in base 10 (including sign, if present).

CalculateLength(short)

Calculates the length of string representation of given number in base 10 (including sign, if present).

CalculateLength(int)

Calculates the length of string representation of given number in base 10 (including sign, if present).

CalculateLength(long)

Calculates the length of string representation of given number in base 10 (including sign, if present).

CalculateLength(sbyte)

Calculates the length of string representation of given number in base 10 (including sign, if present).

CalculateLength(ushort)

Calculates the length of string representation of given number in base 10 (including sign, if present).

CalculateLength(uint)

Calculates the length of string representation of given number in base 10 (including sign, if present).

CalculateLength(ulong)

Calculates the length of string representation of given number in base 10 (including sign, if present).

Deconstruct<TKey, TValue>(KeyValuePair<TKey, TValue>, out TKey, out TValue)

Deconstructs a Dictionary<TKey, TValue> key-value pair item ( KeyValuePair<TKey, TValue>) into 2 separate variables.

This allows for enumerating over dictionaries in foreach blocks by using a (k, v) tuple as the enumerator variable, instead of having to use a KeyValuePair<TKey, TValue> directly.

EndsWithCharacter(string, char)

Tests whether given string ends with given character.

GenerateStreamFromString(string)

Generates a memory stream from a string.

GenerateStringFromStream(Stream)

Generates a string from a stream.

IsBasicAlphanumeric(char)

Returns whether supplied character is in any of the following ranges: a-z, A-Z, 0-9.

IsBasicDigit(char)

Returns whether supplied character is in the 0-9 range.

IsBasicLetter(char)

Returns whether supplied character is in the a-z or A-Z range.

IsInRange(byte, byte, byte, bool)

Tests whether given value is in supplied range, optionally allowing it to be an exclusive check.

IsInRange(double, double, double, bool)

Tests whether given value is in supplied range, optionally allowing it to be an exclusive check.

IsInRange(short, short, short, bool)

Tests whether given value is in supplied range, optionally allowing it to be an exclusive check.

IsInRange(int, int, int, bool)

Tests whether given value is in supplied range, optionally allowing it to be an exclusive check.

IsInRange(long, long, long, bool)

Tests whether given value is in supplied range, optionally allowing it to be an exclusive check.

IsInRange(sbyte, sbyte, sbyte, bool)

Tests whether given value is in supplied range, optionally allowing it to be an exclusive check.

IsInRange(float, float, float, bool)

Tests whether given value is in supplied range, optionally allowing it to be an exclusive check.

IsInRange(ushort, ushort, ushort, bool)

Tests whether given value is in supplied range, optionally allowing it to be an exclusive check.

IsInRange(uint, uint, uint, bool)

Tests whether given value is in supplied range, optionally allowing it to be an exclusive check.

IsInRange(ulong, ulong, ulong, bool)

Tests whether given value is in supplied range, optionally allowing it to be an exclusive check.

Populate<T>(T[], T)

Populates an array with the given value.

RemoveFirst<T>(IList<T>, Predicate<T>)

Removes the first item matching the predicate from the list.

StartsWithCharacter(string, char)

Tests whether given string starts with given character.

TryFirstTwo<T>(IEnumerable<T>, out (T first, T second))

Gets the two first elements of the IEnumerable<T>, if they exist.