Search Results for

    Show / Hide Table of Contents

    Class StringExtensions

    System.String Based Extension Methods

    Inheritance
    System.Object
    StringExtensions
    Namespace: GDX
    Syntax
    [VisualScriptingCompatible((short)2)]
    public static class StringExtensions

    Fields

    | Improve this Doc View Source

    AsciiCaseShift

    The ASCII decimal value shift required to change the case of a letter.

    Declaration
    public const int AsciiCaseShift = 32
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    AsciiLowerCaseEnd

    The ASCII decimal value for lowercase z.

    Declaration
    public const int AsciiLowerCaseEnd = 122
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    AsciiLowerCaseStart

    The ASCII decimal value for a.

    Declaration
    public const int AsciiLowerCaseStart = 97
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    AsciiNumberDecimal

    The ASCII decimal value for the decimal (.).

    Declaration
    public const int AsciiNumberDecimal = 46
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    AsciiNumberEnd

    The ASCII decimal value for 9.

    Declaration
    public const int AsciiNumberEnd = 57
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    AsciiNumberSeparator

    The ASCII decimal value for the , separator.

    Declaration
    public const int AsciiNumberSeparator = 47
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    AsciiNumberSign

    The ASCII decimal value for the number sign -.

    Declaration
    public const int AsciiNumberSign = 45
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    AsciiNumberStart

    The ASCII decimal value for 0.

    Declaration
    public const int AsciiNumberStart = 48
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    AsciiUpperCaseEnd

    The ASCII decimal value for uppercase Z.

    Declaration
    public const int AsciiUpperCaseEnd = 90
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    AsciiUpperCaseStart

    The ASCII decimal value for uppercase A.

    Declaration
    public const int AsciiUpperCaseStart = 65
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    EncryptionDefaultKey

    The default encryption key used when none is provided to the encryption related extensions.

    Declaration
    public static byte[] EncryptionDefaultKey
    Field Value
    Type Description
    System.Byte[]
    Remarks

    You can change this at runtime during some sort of initialization pass to being something unique to your project, but it is not absolutely necessary. This must be a multiple of 8 bytes.

    | Improve this Doc View Source

    EncryptionInitializationVector

    The IV (Initialization Vector) provided to the System.Security.Cryptography.DESCryptoServiceProvider.

    Declaration
    public static byte[] EncryptionInitializationVector
    Field Value
    Type Description
    System.Byte[]
    Remarks

    You can change this at runtime during some sort of initialization pass to being something unique to your project, but it is not absolutely necessary. This must be a multiple of 8 bytes.

    Methods

    | Improve this Doc View Source

    Concatenate(String[], String, Boolean)

    Concatenate an array of strings into one unified string.

    Declaration
    public static string Concatenate(this string[] pieces, string delimiter = null, bool trailingDelimiter = false)
    Parameters
    Type Name Description
    System.String[] pieces

    An array of strings

    System.String delimiter

    An optional string which to use between pieces when combining.

    System.Boolean trailingDelimiter

    Should a trailing delimiter be appended?

    Returns
    Type Description
    System.String

    A concatenated System.String.

    | Improve this Doc View Source

    CountOccurence(String, Char)

    Counts the number of times the needle (targetCharacter) appears in the haystack ( targetString).

    Declaration
    public static int CountOccurence(this string targetString, char targetCharacter)
    Parameters
    Type Name Description
    System.String targetString

    The haystack.

    System.Char targetCharacter

    The needle.

    Returns
    Type Description
    System.Int32

    The number of times targetCharacter is found in targetString.

    Remarks

    Specifically created to avoid using LINQ and avoid an allocation.

    | Improve this Doc View Source

    Decrypt(String, Byte[])

    Decrypt an encrypted System.String created by Encrypt(String, Byte[]).

    Declaration
    public static string Decrypt(this string encryptedString, byte[] encryptionKey = null)
    Parameters
    Type Name Description
    System.String encryptedString

    The encrypted System.String.

    System.Byte[] encryptionKey

    The key used to encrypt the System.String.

    Returns
    Type Description
    System.String

    The decrypted System.String.

    Remarks

    This will have quite a few allocations.

    | Improve this Doc View Source

    Encrypt(String, Byte[])

    Encrypt a System.String utilizing a System.Security.Cryptography.DESCryptoServiceProvider.

    Declaration
    public static string Encrypt(this string decryptedString, byte[] encryptionKey = null)
    Parameters
    Type Name Description
    System.String decryptedString

    The original System.String.

    System.Byte[] encryptionKey

    The key to be used when encrypting the System.String. This must be a multiple of 8 bytes.

    Returns
    Type Description
    System.String

    The encrypted System.String.

    Remarks

    This will have quite a few allocations.

    | Improve this Doc View Source

    GetAfterFirst(String, String, StringComparison)

    Get the System.String after the first identified splitString in targetString.

    Declaration
    public static string GetAfterFirst(this string targetString, string splitString, StringComparison comparison = StringComparison.Ordinal)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String to look in.

    System.String splitString

    The divider which the targetString should be split on.

    System.StringComparison comparison

    Specifies the culture, case, and sort rules to be used.

    Returns
    Type Description
    System.String

    The content following the splitString, or null if none is found.

    | Improve this Doc View Source

    GetAfterLast(String, String, StringComparison)

    Get the System.String after the last identified splitString in targetString.

    Declaration
    public static string GetAfterLast(this string targetString, string splitString, StringComparison comparison = StringComparison.Ordinal)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String to look in.

    System.String splitString

    The divider which the targetString should be split on.

    System.StringComparison comparison

    Specifies the culture, case, and sort rules to be used.

    Returns
    Type Description
    System.String

    The content following the splitString, or null if none is found.

    | Improve this Doc View Source

    GetBeforeFirst(String, String, StringComparison)

    Get the System.String before the first identified splitString in targetString.

    Declaration
    public static string GetBeforeFirst(this string targetString, string splitString, StringComparison comparison = StringComparison.Ordinal)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String to look in.

    System.String splitString

    The divider which the targetString should be split on.

    System.StringComparison comparison

    Specifies the culture, case, and sort rules to be used.

    Returns
    Type Description
    System.String

    The content before the splitString, or null if none is found.

    | Improve this Doc View Source

    GetBeforeLast(String, String, StringComparison)

    Get the System.String before the last identified splitString in targetString.

    Declaration
    public static string GetBeforeLast(this string targetString, string splitString, StringComparison comparison = StringComparison.Ordinal)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String to look in.

    System.String splitString

    The divider which the targetString should be split on.

    System.StringComparison comparison

    Specifies the culture, case, and sort rules to be used.

    Returns
    Type Description
    System.String

    The content before the splitString, or null if none is found.

    | Improve this Doc View Source

    GetStableHashCode(String)

    Get the stable hash code value of targetString.

    Declaration
    public static int GetStableHashCode(this string targetString)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String.

    Returns
    Type Description
    System.Int32

    A System.Int32 value.

    Remarks

    This loosely based on the Fowler–Noll–Vo (FNV) hash function. It's value will be identical to the value produced natively by processing a System.String with System.String.GetHashCode, but with no allocations and no virtual calls.

    | Improve this Doc View Source

    GetStableLowerCaseHashCode(String)

    Get the stable hash code value of targetString (converted to an uppercase System.String).

    Declaration
    public static int GetStableLowerCaseHashCode(this string targetString)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String.

    Returns
    Type Description
    System.Int32

    A System.Int32 value.

    Remarks

    This loosely based on the Fowler–Noll–Vo (FNV) hash function. It's value will be identical to the value produced natively by processing a System.String with System.String.ToLower.System.String.GetHashCode, but with no allocations.

    | Improve this Doc View Source

    GetStableUpperCaseHashCode(String)

    Get the stable hash code value of targetString (converted to an uppercase System.String).

    Declaration
    public static int GetStableUpperCaseHashCode(this string targetString)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String.

    Returns
    Type Description
    System.Int32

    A System.Int32 value.

    Remarks

    This loosely based on the Fowler–Noll–Vo (FNV) hash function. It's value will be identical to the value produced natively by processing a System.String with System.String.ToUpper.System.String.GetHashCode, but with no allocations.

    | Improve this Doc View Source

    HasLowerCase(String)

    Determine if there are any lowercase letters in the provided targetString.

    Declaration
    public static bool HasLowerCase(this string targetString)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String.

    Returns
    Type Description
    System.Boolean

    true/false if lowercase letters were found.

    | Improve this Doc View Source

    HasUpperCase(String)

    Determine if there are any uppercase letters in the provided targetString.

    Declaration
    public static bool HasUpperCase(this string targetString)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String.

    Returns
    Type Description
    System.Boolean

    true/false if uppercase letters were found.

    | Improve this Doc View Source

    IsBooleanPositiveValue(String)

    Determine if the targetString represents a positive boolean value arrangement.

    Declaration
    public static bool IsBooleanPositiveValue(this string targetString)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String.

    Returns
    Type Description
    System.Boolean

    true/false if the targetString can be evaluated as a positive boolean value.

    Examples

    Useful method when trying to parse data for branching.

        if(data["set"].IsBooleanPositiveValue())
        {
            ShouldBlueBox();
        }
    | Improve this Doc View Source

    IsBooleanValue(String)

    Determine if the targetString represents a boolean value arrangement.

    Declaration
    public static bool IsBooleanValue(this string targetString)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String.

    Returns
    Type Description
    System.Boolean

    true/false if the targetString can be evaluated as a boolean value.

    | Improve this Doc View Source

    IsIntegerValue(String)

    Determine if the targetString is an System.Int32 value.

    Declaration
    public static bool IsIntegerValue(this string targetString)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String.

    Returns
    Type Description
    System.Boolean

    true/false if it contains an System.Int32.

    Remarks

    This method is meant for when you do not actually need the value returned, merely an evaluation if the provided targetString is an System.Int32. This does not qualify System.Single values positively.

    | Improve this Doc View Source

    IsNumeric(String)

    Is the targetString a numeric value.

    Declaration
    public static bool IsNumeric(this string targetString)
    Parameters
    Type Name Description
    System.String targetString

    The target System.String.

    Returns
    Type Description
    System.Boolean

    true/false if the targetString qualifies as a numeric value.

    Remarks

    The following requirements must be met to be considered a valid number in this method:

    • The first character may be an indicator of its sign, an explicit acceptance of - is made. If prefixed with +, the number will be found invalid.
    • A single decimal point . may be present in the targetString.
    • No alphabet characters are present in the targetString.
    | Improve this Doc View Source

    PartialMatch(SimpleList<String>, String)

    Does the haystack partially contain the needle?

    Declaration
    public static bool PartialMatch(this SimpleList<string> haystack, string needle)
    Parameters
    Type Name Description
    SimpleList<System.String> haystack

    A SimpleList<T> of System.Strings.

    System.String needle

    The System.String that is being looked for.

    Returns
    Type Description
    System.Boolean

    true/false if found.

    | Improve this Doc View Source

    PartialMatch(String[], String)

    Does the haystack partially contain the needle?

    Declaration
    public static bool PartialMatch(this string[] haystack, string needle)
    Parameters
    Type Name Description
    System.String[] haystack

    An array of System.Strings.

    System.String needle

    The System.String that is being looked for.

    Returns
    Type Description
    System.Boolean

    true/false if found.

    | Improve this Doc View Source

    SplitCamelCase(String, String)

    Create a new string, splitting an existing string up based on camel case formatting.

    Declaration
    public static string SplitCamelCase(this string targetString, string divider = " ")
    Parameters
    Type Name Description
    System.String targetString

    The target System.String.

    System.String divider

    The System.String to put in between the split System.String.

    Returns
    Type Description
    System.String

    A new System.String.

    | Improve this Doc View Source

    StripNonAscii(String)

    Remove non ASCII characters from a System.String.

    Declaration
    public static string StripNonAscii(this string targetString)
    Parameters
    Type Name Description
    System.String targetString

    The System.String to be cleaned.

    Returns
    Type Description
    System.String

    A System.String without ASCII characters.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Built on 2024-01-01 against 1f69a68.
    Generated by Dox+DocFX.