Unosquare
    Show / Hide Table of Contents

    Class StringExtensions

    Provides extension methods for String.

    Inheritance
    Object
    StringExtensions
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: EmbedIO.Utilities
    Syntax
    public static class StringExtensions

    Methods

    NullIfEmpty(String)

    Ensures that a String is never empty, by transforming empty strings into null.

    Declaration
    public static string NullIfEmpty(this string this)
    Parameters
    Type Name Description
    String this

    The String on which this method is called.

    Returns
    Type Description
    String

    If this is the empty string, null; otherwise, this..

    SplitByAny(String, Char[])

    Splits a string into substrings based on the specified delimiters. The returned array includes empty array elements if two or more consecutive delimiters are found in this.

    Declaration
    public static string[] SplitByAny(this string this, params char[] delimiters)
    Parameters
    Type Name Description
    String this

    The String on which this method is called.

    Char[] delimiters

    An array of Chars to use as delimiters.

    Returns
    Type Description
    String[]

    An array whose elements contain the substrings in this that are delimited by one or more characters in delimiters.

    SplitByComma(String)

    Splits a string into substrings, using the comma (,) character as a delimiter. The returned array includes empty array elements if two or more commas are found in this.

    Declaration
    public static string[] SplitByComma(this string this)
    Parameters
    Type Name Description
    String this

    The String on which this method is called.

    Returns
    Type Description
    String[]

    An array whose elements contain the substrings in this that are delimited by commas.

    See Also
    SplitByComma(String, StringSplitOptions)

    SplitByComma(String, StringSplitOptions)

    Splits a string into substrings, using the comma (,) character as a delimiter. You can specify whether the substrings include empty array elements.

    Declaration
    public static string[] SplitByComma(this string this, StringSplitOptions options)
    Parameters
    Type Name Description
    String this

    The String on which this method is called.

    StringSplitOptions options

    to omit empty array elements from the array returned; or to include empty array elements in the array returned.

    Returns
    Type Description
    String[]

    An array whose elements contain the substrings in this that are delimited by commas.

    For more information, see the Remarks section of the method.

    See Also
    SplitByComma(String)

    TrimmedSubstring(String, Int32)

    Retrieves a substring from this instance, with leading and trailing white-space characters removed. The substring starts at a specified character position and continues to the end of the string.

    Declaration
    public static string TrimmedSubstring(this string this, int startIndex)
    Parameters
    Type Name Description
    String this

    The String on which this method is called.

    Int32 startIndex

    The zero-based starting character position of the substring to retrieve.

    Returns
    Type Description
    String

    A string that is equivalent to the substring that begins at startIndex in this, minus any leading and/or trailing white-space characters.

    TrimmedSubstring(String, Int32, Int32)

    Retrieves a substring from this instance, with leading and trailing white-space characters removed. The substring starts at a specified character position and has a specified length.

    Declaration
    public static string TrimmedSubstring(this string this, int startIndex, int length)
    Parameters
    Type Name Description
    String this

    The String on which this method is called.

    Int32 startIndex

    The zero-based starting character position of the substring to retrieve.

    Int32 length

    The length of the substring to retrieve, including leading and/or trailing white-space characters.

    Returns
    Type Description
    String

    A string that is equivalent to the substring of length length that begins at startIndex in this, minus any leading and/or trailing white-space characters.

    Comments

    Back to top Copyright © 2017-2019 Unosquare