Search Results for

    Show / Hide Table of Contents

    Class Extensions

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

    Inheritance
    System.Object
    Extensions
    Namespace: DisCatSharp.Common
    Assembly: DisCatSharp.Common.dll
    Syntax
    public static class Extensions

    Methods

    | Improve this Doc View Source

    CalculateKnuthHash(ArraySegment<Char>)

    Computes a 64-bit Knuth hash from supplied characters.

    Declaration
    public static ulong CalculateKnuthHash(this ArraySegment<char> chars)
    Parameters
    Type Name Description
    System.ArraySegment<System.Char> chars

    Characters to compute the hash value from.

    Returns
    Type Description
    System.UInt64

    Computer 64-bit Knuth hash.

    | Improve this Doc View Source

    CalculateKnuthHash(Char[])

    Computes a 64-bit Knuth hash from supplied characters.

    Declaration
    public static ulong CalculateKnuthHash(this char[] chars)
    Parameters
    Type Name Description
    System.Char[] chars

    Characters to compute the hash value from.

    Returns
    Type Description
    System.UInt64

    Computer 64-bit Knuth hash.

    | Improve this Doc View Source

    CalculateKnuthHash(Char[], Int32, Int32)

    Computes a 64-bit Knuth hash from supplied characters.

    Declaration
    public static ulong CalculateKnuthHash(this char[] chars, int start, int count)
    Parameters
    Type Name Description
    System.Char[] chars

    Characters to compute the hash value from.

    System.Int32 start

    Offset in the array to start calculating from.

    System.Int32 count

    Number of characters to compute the hash from.

    Returns
    Type Description
    System.UInt64

    Computer 64-bit Knuth hash.

    | Improve this Doc View Source

    CalculateKnuthHash(Memory<Char>)

    Computes a 64-bit Knuth hash from supplied characters.

    Declaration
    public static ulong CalculateKnuthHash(this Memory<char> chars)
    Parameters
    Type Name Description
    System.Memory<System.Char> chars

    Characters to compute the hash value from.

    Returns
    Type Description
    System.UInt64

    Computer 64-bit Knuth hash.

    | Improve this Doc View Source

    CalculateKnuthHash(ReadOnlyMemory<Char>)

    Computes a 64-bit Knuth hash from supplied characters.

    Declaration
    public static ulong CalculateKnuthHash(this ReadOnlyMemory<char> chars)
    Parameters
    Type Name Description
    System.ReadOnlyMemory<System.Char> chars

    Characters to compute the hash value from.

    Returns
    Type Description
    System.UInt64

    Computer 64-bit Knuth hash.

    | Improve this Doc View Source

    CalculateKnuthHash(ReadOnlySpan<Char>)

    Computes a 64-bit Knuth hash from supplied characters.

    Declaration
    public static ulong CalculateKnuthHash(this ReadOnlySpan<char> chars)
    Parameters
    Type Name Description
    System.ReadOnlySpan<System.Char> chars

    Characters to compute the hash value from.

    Returns
    Type Description
    System.UInt64

    Computer 64-bit Knuth hash.

    | Improve this Doc View Source

    CalculateKnuthHash(Span<Char>)

    Computes a 64-bit Knuth hash from supplied characters.

    Declaration
    public static ulong CalculateKnuthHash(this Span<char> chars)
    Parameters
    Type Name Description
    System.Span<System.Char> chars

    Characters to compute the hash value from.

    Returns
    Type Description
    System.UInt64

    Computer 64-bit Knuth hash.

    | Improve this Doc View Source

    CalculateKnuthHash(String)

    Computes a 64-bit Knuth hash from supplied characters.

    Declaration
    public static ulong CalculateKnuthHash(this string chars)
    Parameters
    Type Name Description
    System.String chars

    Characters to compute the hash value from.

    Returns
    Type Description
    System.UInt64

    Computer 64-bit Knuth hash.

    | Improve this Doc View Source

    CalculateKnuthHash(String, Int32, Int32)

    Computes a 64-bit Knuth hash from supplied characters.

    Declaration
    public static ulong CalculateKnuthHash(this string chars, int start, int count)
    Parameters
    Type Name Description
    System.String chars

    Characters to compute the hash value from.

    System.Int32 start

    Offset in the array to start calculating from.

    System.Int32 count

    Number of characters to compute the hash from.

    Returns
    Type Description
    System.UInt64

    Computer 64-bit Knuth hash.

    | Improve this Doc View Source

    CalculateLength(Byte)

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

    Declaration
    public static int CalculateLength(this byte num)
    Parameters
    Type Name Description
    System.Byte num

    Number to calculate the length of.

    Returns
    Type Description
    System.Int32

    Calculated number length.

    | Improve this Doc View Source

    CalculateLength(Int16)

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

    Declaration
    public static int CalculateLength(this short num)
    Parameters
    Type Name Description
    System.Int16 num

    Number to calculate the length of.

    Returns
    Type Description
    System.Int32

    Calculated number length.

    | Improve this Doc View Source

    CalculateLength(Int32)

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

    Declaration
    public static int CalculateLength(this int num)
    Parameters
    Type Name Description
    System.Int32 num

    Number to calculate the length of.

    Returns
    Type Description
    System.Int32

    Calculated number length.

    | Improve this Doc View Source

    CalculateLength(Int64)

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

    Declaration
    public static int CalculateLength(this long num)
    Parameters
    Type Name Description
    System.Int64 num

    Number to calculate the length of.

    Returns
    Type Description
    System.Int32

    Calculated number length.

    | Improve this Doc View Source

    CalculateLength(SByte)

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

    Declaration
    public static int CalculateLength(this sbyte num)
    Parameters
    Type Name Description
    System.SByte num

    Number to calculate the length of.

    Returns
    Type Description
    System.Int32

    Calculated number length.

    | Improve this Doc View Source

    CalculateLength(UInt16)

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

    Declaration
    public static int CalculateLength(this ushort num)
    Parameters
    Type Name Description
    System.UInt16 num

    Number to calculate the length of.

    Returns
    Type Description
    System.Int32

    Calculated number length.

    | Improve this Doc View Source

    CalculateLength(UInt32)

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

    Declaration
    public static int CalculateLength(this uint num)
    Parameters
    Type Name Description
    System.UInt32 num

    Number to calculate the length of.

    Returns
    Type Description
    System.Int32

    Calculated number length.

    | Improve this Doc View Source

    CalculateLength(UInt64)

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

    Declaration
    public static int CalculateLength(this ulong num)
    Parameters
    Type Name Description
    System.UInt64 num

    Number to calculate the length of.

    Returns
    Type Description
    System.Int32

    Calculated number length.

    | Improve this Doc View Source

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

    Deconstructs a System.Collections.Generic.Dictionary<TKey, TValue> key-value pair item (System.Collections.Generic.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 System.Collections.Generic.KeyValuePair<TKey, TValue> directly.

    Declaration
    public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> kvp, out TKey key, out TValue value)
    Parameters
    Type Name Description
    System.Collections.Generic.KeyValuePair<TKey, TValue> kvp

    Key-value pair to deconstruct.

    TKey key

    Deconstructed key.

    TValue value

    Deconstructed value.

    Type Parameters
    Name Description
    TKey

    Type of dictionary item key.

    TValue

    Type of dictionary item value.

    | Improve this Doc View Source

    EndsWithCharacter(String, Char)

    Tests whether given string ends with given character.

    Declaration
    public static bool EndsWithCharacter(this string s, char c)
    Parameters
    Type Name Description
    System.String s

    String to test.

    System.Char c

    Character to test for.

    Returns
    Type Description
    System.Boolean

    Whether the supplied string ends with supplied character.

    | Improve this Doc View Source

    IsBasicAlphanumeric(Char)

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

    Declaration
    public static bool IsBasicAlphanumeric(this char c)
    Parameters
    Type Name Description
    System.Char c

    Character to test.

    Returns
    Type Description
    System.Boolean

    Whether the character is in basic alphanumeric character range.

    | Improve this Doc View Source

    IsBasicDigit(Char)

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

    Declaration
    public static bool IsBasicDigit(this char c)
    Parameters
    Type Name Description
    System.Char c

    Character to test.

    Returns
    Type Description
    System.Boolean

    Whether the character is in basic numeric digit character range.

    | Improve this Doc View Source

    IsBasicLetter(Char)

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

    Declaration
    public static bool IsBasicLetter(this char c)
    Parameters
    Type Name Description
    System.Char c

    Character to test.

    Returns
    Type Description
    System.Boolean

    Whether the character is in basic letter character range.

    | Improve this Doc View Source

    IsInRange(Byte, Byte, Byte, Boolean)

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

    Declaration
    public static bool IsInRange(this byte num, byte min, byte max, bool inclusive = true)
    Parameters
    Type Name Description
    System.Byte num

    Number to test.

    System.Byte min

    Lower bound of the range.

    System.Byte max

    Upper bound of the range.

    System.Boolean inclusive

    Whether the check is to be inclusive.

    Returns
    Type Description
    System.Boolean

    Whether the value is in range.

    | Improve this Doc View Source

    IsInRange(Double, Double, Double, Boolean)

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

    Declaration
    public static bool IsInRange(this double num, double min, double max, bool inclusive = true)
    Parameters
    Type Name Description
    System.Double num

    Number to test.

    System.Double min

    Lower bound of the range.

    System.Double max

    Upper bound of the range.

    System.Boolean inclusive

    Whether the check is to be inclusive.

    Returns
    Type Description
    System.Boolean

    Whether the value is in range.

    | Improve this Doc View Source

    IsInRange(Int16, Int16, Int16, Boolean)

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

    Declaration
    public static bool IsInRange(this short num, short min, short max, bool inclusive = true)
    Parameters
    Type Name Description
    System.Int16 num

    Number to test.

    System.Int16 min

    Lower bound of the range.

    System.Int16 max

    Upper bound of the range.

    System.Boolean inclusive

    Whether the check is to be inclusive.

    Returns
    Type Description
    System.Boolean

    Whether the value is in range.

    | Improve this Doc View Source

    IsInRange(Int32, Int32, Int32, Boolean)

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

    Declaration
    public static bool IsInRange(this int num, int min, int max, bool inclusive = true)
    Parameters
    Type Name Description
    System.Int32 num

    Number to test.

    System.Int32 min

    Lower bound of the range.

    System.Int32 max

    Upper bound of the range.

    System.Boolean inclusive

    Whether the check is to be inclusive.

    Returns
    Type Description
    System.Boolean

    Whether the value is in range.

    | Improve this Doc View Source

    IsInRange(Int64, Int64, Int64, Boolean)

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

    Declaration
    public static bool IsInRange(this long num, long min, long max, bool inclusive = true)
    Parameters
    Type Name Description
    System.Int64 num

    Number to test.

    System.Int64 min

    Lower bound of the range.

    System.Int64 max

    Upper bound of the range.

    System.Boolean inclusive

    Whether the check is to be inclusive.

    Returns
    Type Description
    System.Boolean

    Whether the value is in range.

    | Improve this Doc View Source

    IsInRange(SByte, SByte, SByte, Boolean)

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

    Declaration
    public static bool IsInRange(this sbyte num, sbyte min, sbyte max, bool inclusive = true)
    Parameters
    Type Name Description
    System.SByte num

    Number to test.

    System.SByte min

    Lower bound of the range.

    System.SByte max

    Upper bound of the range.

    System.Boolean inclusive

    Whether the check is to be inclusive.

    Returns
    Type Description
    System.Boolean

    Whether the value is in range.

    | Improve this Doc View Source

    IsInRange(Single, Single, Single, Boolean)

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

    Declaration
    public static bool IsInRange(this float num, float min, float max, bool inclusive = true)
    Parameters
    Type Name Description
    System.Single num

    Number to test.

    System.Single min

    Lower bound of the range.

    System.Single max

    Upper bound of the range.

    System.Boolean inclusive

    Whether the check is to be inclusive.

    Returns
    Type Description
    System.Boolean

    Whether the value is in range.

    | Improve this Doc View Source

    IsInRange(UInt16, UInt16, UInt16, Boolean)

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

    Declaration
    public static bool IsInRange(this ushort num, ushort min, ushort max, bool inclusive = true)
    Parameters
    Type Name Description
    System.UInt16 num

    Number to test.

    System.UInt16 min

    Lower bound of the range.

    System.UInt16 max

    Upper bound of the range.

    System.Boolean inclusive

    Whether the check is to be inclusive.

    Returns
    Type Description
    System.Boolean

    Whether the value is in range.

    | Improve this Doc View Source

    IsInRange(UInt32, UInt32, UInt32, Boolean)

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

    Declaration
    public static bool IsInRange(this uint num, uint min, uint max, bool inclusive = true)
    Parameters
    Type Name Description
    System.UInt32 num

    Number to test.

    System.UInt32 min

    Lower bound of the range.

    System.UInt32 max

    Upper bound of the range.

    System.Boolean inclusive

    Whether the check is to be inclusive.

    Returns
    Type Description
    System.Boolean

    Whether the value is in range.

    | Improve this Doc View Source

    IsInRange(UInt64, UInt64, UInt64, Boolean)

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

    Declaration
    public static bool IsInRange(this ulong num, ulong min, ulong max, bool inclusive = true)
    Parameters
    Type Name Description
    System.UInt64 num

    Number to test.

    System.UInt64 min

    Lower bound of the range.

    System.UInt64 max

    Upper bound of the range.

    System.Boolean inclusive

    Whether the check is to be inclusive.

    Returns
    Type Description
    System.Boolean

    Whether the value is in range.

    | Improve this Doc View Source

    StartsWithCharacter(String, Char)

    Tests whether given string starts with given character.

    Declaration
    public static bool StartsWithCharacter(this string s, char c)
    Parameters
    Type Name Description
    System.String s

    String to test.

    System.Char c

    Character to test for.

    Returns
    Type Description
    System.Boolean

    Whether the supplied string starts with supplied character.

    • Improve this Doc
    • View Source
    In This Article
    Back to top © 2021-2022 Aiko IT Systems