JK
Search Results for

    Show / Hide Table of Contents

    Class StringExtensions

    Extension methods for the String object.

    Inheritance
    System.Object
    StringExtensions
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: JK.Common.Extensions
    Assembly: JK.Common.dll
    Syntax
    public static class StringExtensions

    Methods

    | Improve this Doc View Source

    ConvertNullToEmptyString(String)

    Declaration
    public static string ConvertNullToEmptyString(this string value)
    Parameters
    Type Name Description
    System.String value
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    IsDateTime(String)

    Determines if the given string is a date/time. Relies on DateTimeSpecification

    Declaration
    public static bool IsDateTime(this string valueToValidate)
    Parameters
    Type Name Description
    System.String valueToValidate

    Current string object from extension method.

    Returns
    Type Description
    System.Boolean

    True if a date, otherwise false.

    | Improve this Doc View Source

    IsNumeric(String)

    Determines if the given string is a number. Relies on NumericSpecification

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

    Current string object from extension method.

    Returns
    Type Description
    System.Boolean

    True if a number, otherwise false.

    | Improve this Doc View Source

    IsValidEmailAddress(String)

    Validates that a string is a valid email address. Relies on EmailSpecification

    Declaration
    public static bool IsValidEmailAddress(this string valueToValidate)
    Parameters
    Type Name Description
    System.String valueToValidate

    Current string object from extension method.

    Returns
    Type Description
    System.Boolean

    True if valid email otherwise false.

    | Improve this Doc View Source

    IsValidIpAddress(String)

    Validates that a string is a valid IP v4 address. Relies on InternetProtocolAddressSpecification

    Declaration
    public static bool IsValidIpAddress(this string valueToValidate)
    Parameters
    Type Name Description
    System.String valueToValidate

    Current string object from extension method.

    Returns
    Type Description
    System.Boolean

    True if valid IP v4 address otherwise false.

    | Improve this Doc View Source

    IsValidUnitedStatesPhoneNumber(String)

    Validates that a string is a valid United States phone number. Relies on PhoneNumberSpecification

    Declaration
    public static bool IsValidUnitedStatesPhoneNumber(this string valueToValidate)
    Parameters
    Type Name Description
    System.String valueToValidate

    Current string object from extension method.

    Returns
    Type Description
    System.Boolean

    True if valid US phone number otherwise false.

    | Improve this Doc View Source

    IsValidZip(String)

    Validates that a string is a valid zip code. Relies on ZipCodeSpecification

    Declaration
    public static bool IsValidZip(this string valueToValidate)
    Parameters
    Type Name Description
    System.String valueToValidate

    Current string object from extension method.

    Returns
    Type Description
    System.Boolean

    True if valid zip code otherwise false.

    | Improve this Doc View Source

    Last(String, in Int32)

    Returns the specified number of characters from a string. Same as Last()

    Declaration
    public static string Last(this string value, in int length)
    Parameters
    Type Name Description
    System.String value

    Current string object from extension method.

    System.Int32 length

    Number of characters to get from end of string.

    Returns
    Type Description
    System.String

    Returns the last X characters of the string.

    | Improve this Doc View Source

    RemoveUnitedStatesCurrencyFormat(String)

    Removes US (dollar) currency format characters from a string.

    Declaration
    public static string RemoveUnitedStatesCurrencyFormat(this string valueToFormat)
    Parameters
    Type Name Description
    System.String valueToFormat

    Current string object from extension method.

    Returns
    Type Description
    System.String

    String that can be parsed into a number.

    | Improve this Doc View Source

    Reverse(String)

    Reverses the characters within a string.

    Declaration
    public static string Reverse(this string valueToReverse)
    Parameters
    Type Name Description
    System.String valueToReverse

    Current string object from extension method.

    Returns
    Type Description
    System.String

    The original string in reverse.

    | Improve this Doc View Source

    Right(String, in Int32)

    Returns the specified number of characters from a string. Same as Last()

    Declaration
    public static string Right(this string value, in int length)
    Parameters
    Type Name Description
    System.String value

    Current string object from extension method.

    System.Int32 length

    Number of characters to get from end of string.

    Returns
    Type Description
    System.String

    Returns the last X characters of the string.

    | Improve this Doc View Source

    StripXml(String)

    Removes XML/HTML from given text block.

    Declaration
    public static string StripXml(this string valueToStrip)
    Parameters
    Type Name Description
    System.String valueToStrip

    Current string object from extension method.

    Returns
    Type Description
    System.String

    Clean string with no XML/HTML.

    | Improve this Doc View Source

    Truncate(String, in Int32)

    Trims a block of text to a specified length. The string will be trimmed to the previous space coming before the length position passed. Relies on StringTruncater

    Declaration
    public static string Truncate(this string valueToTruncate, in int length)
    Parameters
    Type Name Description
    System.String valueToTruncate

    Current string object from extension method.

    System.Int32 length

    Number of characters to keep from the original string.

    Returns
    Type Description
    System.String

    Truncated, or shortened, text.

    | Improve this Doc View Source

    Truncate(String, in Int32, in String)

    Trims a block of text to a specified length. The string will be trimmed to the previous space coming before the length position passed. Relies on StringTruncater

    Declaration
    public static string Truncate(this string valueToTruncate, in int length, in string indicator)
    Parameters
    Type Name Description
    System.String valueToTruncate

    Current string object from extension method.

    System.Int32 length

    Number of characters to keep from the original string.

    System.String indicator

    String of characters to indicate that a truncation has occurred.

    Returns
    Type Description
    System.String

    Truncated, or shortened, text with an indicator marking where the truncation occurred.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © Jeremy Knight. Generated with DocFX