String Class

Represents text as a sequence of UTF-16 code units.

Syntax

Declaration

[ComVisible(true)]
[Serializable]
public sealed class String : IComparable, ICloneable, IConvertible, IComparable<string>, IEnumerable<char>, IEnumerable, IEquatable<string>

Inheritance Hierarchy

Inherited Members

System.Object

, , ,

Constructors summary

Initializes a new instance of the String class to the value indicated by a specified pointer to an array of Unicode characters.

Initializes a new instance of the String class to the value indicated by a specified pointer to an array of Unicode characters, a starting character position within that array, and a length.

Initializes a new instance of the String class to the value indicated by a specified Unicode character repeated a specified number of times.

Initializes a new instance of the String class to the value indicated by an array of Unicode characters.

Initializes a new instance of the String class to the value indicated by an array of Unicode characters, a starting character position within that array, and a length.

Fields summary

Represents the empty string. This field is read-only.

Properties summary

Gets the Char object at a specified position in the current String object.

Gets the number of characters in the current String object.

Methods summary

Compares substrings of two specified String objects and returns an integer that indicates their relative position in the sort order.

Compares substrings of two specified String objects using the specified rules, and returns an integer that indicates their relative position in the sort order.

Compares two specified String objects and returns an integer that indicates their relative position in the sort order.

Compares two specified String objects, ignoring or honoring their case, and returns an integer that indicates their relative position in the sort order.

Compares two specified String objects using the specified rules, and returns an integer that indicates their relative position in the sort order.

Compares substrings of two specified String objects by evaluating the numeric values of the corresponding Char objects in each substring.

Compares two specified String objects by evaluating the numeric values of the corresponding Char objects in each string.

Compares this instance with a specified String object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified string.

Concatenates the members of a constructed IEnumerable<T> collection of type String.

Creates the string representation of a specified object.

Concatenates the string representations of two specified objects.

Concatenates the string representations of three specified objects.

Concatenates the string representations of the elements in a specified Object array.

Concatenates two specified instances of String.

Concatenates three specified instances of String.

Concatenates four specified instances of String.

Concatenates the elements of a specified String array.

Concatenates the members of an IEnumerable<T> implementation.

Returns a value indicating whether a specified substring occurs within this string.

Copies a specified number of characters from a specified position in this instance to a specified position in an array of Unicode characters.

Determines whether the end of this string instance matches the specified string.

Determines whether the end of this string instance matches the specified string when compared using the specified comparison option.

Determines whether this instance and a specified object, which must also be a String object, have the same value.

Determines whether this instance and another specified String object have the same value.

Determines whether two specified String objects have the same value.

Determines whether two specified String objects have the same value. A parameter specifies the culture, case, and sort rules used in the comparison.

Determines whether this string and a specified String object have the same value. A parameter specifies the culture, case, and sort rules used in the comparison.

Replaces the format item or items in a specified string with the string representation of the corresponding object. A parameter supplies culture-specific formatting information.

Replaces the format items in a specified string with the string representation of two specified objects. A parameter supplies culture-specific formatting information.

Replaces the format items in a specified string with the string representation of three specified objects. An parameter supplies culture-specific formatting information.

Replaces the format items in a specified string with the string representations of corresponding objects in a specified array. A parameter supplies culture-specific formatting information.

Replaces one or more format items in a specified string with the string representation of a specified object.

Replaces the format items in a specified string with the string representation of two specified objects.

Replaces the format items in a specified string with the string representation of three specified objects.

Replaces the format item in a specified string with the string representation of a corresponding object in a specified array.

Returns the hash code for this string.

Reports the zero-based index of the first occurrence of the specified Unicode character in this string.

Reports the zero-based index of the first occurrence of the specified Unicode character in this string. The search starts at a specified character position.

Reports the zero-based index of the first occurrence of the specified character in this instance. The search starts at a specified character position and examines a specified number of character positions.

Reports the zero-based index of the first occurrence of the specified string in this instance.

Reports the zero-based index of the first occurrence of the specified string in this instance. The search starts at a specified character position.

Reports the zero-based index of the first occurrence of the specified string in this instance. The search starts at a specified character position and examines a specified number of character positions.

Reports the zero-based index of the first occurrence of the specified string in the current String object. Parameters specify the starting search position in the current string, the number of characters in the current string to search, and the type of search to use for the specified string.

Reports the zero-based index of the first occurrence of the specified string in the current String object. Parameters specify the starting search position in the current string and the type of search to use for the specified string.

Reports the zero-based index of the first occurrence of the specified string in the current String object. A parameter specifies the type of search to use for the specified string.

Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters.

Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters. The search starts at a specified character position.

Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters. The search starts at a specified character position and examines a specified number of character positions.

Returns a new string in which a specified string is inserted at a specified index position in this instance.

Indicates whether the specified string is null or an Empty string.

Indicates whether a specified string is null, empty, or consists only of white-space characters.

Concatenates the members of a constructed IEnumerable<T> collection of type String, using the specified separator between each member.

Concatenates the elements of an object array, using the specified separator between each element.

Concatenates all the elements of a string array, using the specified separator between each element.

Concatenates the specified elements of a string array, using the specified separator between each element.

Concatenates the members of a collection, using the specified separator between each member.

Reports the zero-based index position of the last occurrence of a specified Unicode character within this instance.

Reports the zero-based index position of the last occurrence of a specified Unicode character within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string.

Reports the zero-based index position of the last occurrence of the specified Unicode character in a substring within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string for a specified number of character positions.

Reports the zero-based index position of the last occurrence of a specified string within this instance.

Reports the zero-based index position of the last occurrence of a specified string within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string.

Reports the zero-based index position of the last occurrence of a specified string within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string for a specified number of character positions.

Reports the zero-based index position of the last occurrence of a specified string within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string for the specified number of character positions. A parameter specifies the type of comparison to perform when searching for the specified string.

Reports the zero-based index of the last occurrence of a specified string within the current String object. The search starts at a specified character position and proceeds backward toward the beginning of the string. A parameter specifies the type of comparison to perform when searching for the specified string.

Reports the zero-based index of the last occurrence of a specified string within the current String object. A parameter specifies the type of search to use for the specified string.

Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array.

Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array. The search starts at a specified character position and proceeds backward toward the beginning of the string.

Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array. The search starts at a specified character position and proceeds backward toward the beginning of the string for a specified number of character positions.

Returns a new string that right-aligns the characters in this instance by padding them with spaces on the left, for a specified total length.

Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a specified total length.

Returns a new string that left-aligns the characters in this string by padding them with spaces on the right, for a specified total length.

Returns a new string that left-aligns the characters in this string by padding them on the right with a specified Unicode character, for a specified total length.

Returns a new string in which all the characters in the current instance, beginning at a specified position and continuing through the last position, have been deleted.

Returns a new string in which a specified number of characters in the current instance beginning at a specified position have been deleted.

Returns a new string in which all occurrences of a specified Unicode character in this instance are replaced with another specified Unicode character.

Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string.

Splits a string into substrings that are based on the characters in an array.

Splits a string into a maximum number of substrings based on the characters in an array. You also specify the maximum number of substrings to return.

Splits a string into a maximum number of substrings based on the characters in an array.

Splits a string into substrings based on the characters in an array. You can specify whether the substrings include empty array elements.

Splits a string into a maximum number of substrings based on the strings in an array. You can specify whether the substrings include empty array elements.

Splits a string into substrings based on the strings in an array. You can specify whether the substrings include empty array elements.

Determines whether the beginning of this string instance matches the specified string.

Determines whether the beginning of this string instance matches the specified string when compared using the specified comparison option.

Retrieves a substring from this instance. The substring starts at a specified character position and continues to the end of the string.

Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.

Copies the characters in this instance to a Unicode character array.

Copies the characters in a specified substring in this instance to a Unicode character array.

Returns a copy of this string converted to lowercase.

Returns a copy of this String object converted to lowercase using the casing rules of the invariant culture.

Returns this instance of String; no actual conversion is performed.

Returns a copy of this string converted to uppercase.

Returns a copy of this String object converted to uppercase using the casing rules of the invariant culture.

Removes all leading and trailing white-space characters from the current String object.

Removes all leading and trailing occurrences of a set of characters specified in an array from the current String object.

Removes all trailing occurrences of a set of characters specified in an array from the current String object.

Removes all leading occurrences of a set of characters specified in an array from the current String object.

Operators summary

Determines whether two specified strings have the same value.

Determines whether two specified strings have different values.

Explicit Interface Implementations summary

Returns an enumerator that iterates through the current String object.

For a description of this member, see ToBoolean(IFormatProvider).

For a description of this member, see ToByte(IFormatProvider).

For a description of this member, see ToChar(IFormatProvider).

For a description of this member, see ToDateTime(IFormatProvider).

For a description of this member, see ToDecimal(IFormatProvider).

For a description of this member, see ToDouble(IFormatProvider).

For a description of this member, see ToInt16(IFormatProvider).

For a description of this member, see ToInt32(IFormatProvider).

For a description of this member, see ToInt64(IFormatProvider).

For a description of this member, see ToSByte(IFormatProvider).

For a description of this member, see ToSingle(IFormatProvider).

For a description of this member, see ToType(Type, IFormatProvider).

For a description of this member, see ToUInt16(IFormatProvider).

For a description of this member, see ToUInt32(IFormatProvider).

For a description of this member, see ToUInt64(IFormatProvider).

Constructors

  • String(Char*)

    Initializes a new instance of the String class to the value indicated by a specified pointer to an array of Unicode characters.

    [SecurityCritical]
    [CLSCompliant(false)]
    public String(char *value)

    Parameters

    • value

      A pointer to a null-terminated array of Unicode characters.

    Exceptions

    • The current process does not have read access to all the addressed characters.

    • value specifies an array that contains an invalid Unicode character, or value specifies an address less than 64000.

  • String(Char*, Int32, Int32)

    Initializes a new instance of the String class to the value indicated by a specified pointer to an array of Unicode characters, a starting character position within that array, and a length.

    [SecurityCritical]
    [CLSCompliant(false)]
    public String(char *value, int startIndex, int length)

    Parameters

    • value

      A pointer to an array of Unicode characters.

    • startIndex

      The starting position within value.

    • length

      The number of characters within value to use.

    Exceptions

    • startIndex or length is less than zero, value + startIndex cause a pointer overflow, or the current process does not have read access to all the addressed characters.

    • value specifies an array that contains an invalid Unicode character, or value + startIndex specifies an address less than 64000.

  • String(Char, Int32)

    Initializes a new instance of the String class to the value indicated by a specified Unicode character repeated a specified number of times.

    public String(char c, int count)

    Parameters

    • c

      A Unicode character.

    • count

      The number of times c occurs.

    Exceptions

  • String(Char[])

    Initializes a new instance of the String class to the value indicated by an array of Unicode characters.

    public String(char[] value)

    Parameters

    • value

      An array of Unicode characters.

  • String(Char[], Int32, Int32)

    Initializes a new instance of the String class to the value indicated by an array of Unicode characters, a starting character position within that array, and a length.

    public String(char[] value, int startIndex, int length)

    Parameters

    • value

      An array of Unicode characters.

    • startIndex

      The starting position within value.

    • length

      The number of characters within value to use.

    Exceptions

Fields

  • Empty

    Represents the empty string. This field is read-only.

    public static readonly string Empty

Properties

  • Chars[Int32]

    Gets the Char object at a specified position in the current String object.

    public char this[int index] { get; }

    Parameters

    • index

      A position in the current string.

    Property Value

    • The object at position index.

    Exceptions

  • Length

    Gets the number of characters in the current String object.

    public int Length { get; }

    Property Value

    • The number of characters in the current string.

Methods

  • Compare(String, Int32, String, Int32, Int32)

    Compares substrings of two specified String objects and returns an integer that indicates their relative position in the sort order.

    public static int Compare(string strA, int indexA, string strB, int indexB, int length)

    Parameters

    • strA

      The first string to use in the comparison.

    • indexA

      The position of the substring within strA.

    • strB

      The second string to use in the comparison.

    • indexB

      The position of the substring within strB.

    • length

      The maximum number of characters in the substrings to compare.

    Returns

    • A 32-bit signed integer indicating the lexical relationship between the two comparands.

      Value

      Condition

      Less than zero

      The substring in strA precedes the substring in strB in the sort order.

      Zero

      The substrings occur in the same position in the sort order, or length is zero.

      Greater than zero

      The substring in strA follows the substring in strB in the sort order.

    Exceptions

    • indexA is greater than strA.Length.

      -or-

      indexB is greater than strB.Length.

      -or-

      indexA, indexB, or length is negative.

      -or-

      Either indexA or indexB is null, and length is greater than zero.

  • Compare(String, Int32, String, Int32, Int32, StringComparison)

    Compares substrings of two specified String objects using the specified rules, and returns an integer that indicates their relative position in the sort order.

    public static int Compare(string strA, int indexA, string strB, int indexB, int length, StringComparison comparisonType)

    Parameters

    • strA

      The first string to use in the comparison.

    • indexA

      The position of the substring within strA.

    • strB

      The second string to use in the comparison.

    • indexB

      The position of the substring within strB.

    • length

      The maximum number of characters in the substrings to compare.

    • comparisonType

      One of the enumeration values that specifies the rules to use in the comparison.

    Returns

    • A 32-bit signed integer that indicates the lexical relationship between the two comparands.

      Value

      Condition

      Less than zero

      The substring in strA precedes the substring in strB in the sort order.

      Zero

      The substrings occur in the same position in the sort order, or the length parameter is zero.

      Greater than zero

      The substring in strA follllows the substring in strB in the sort order.

    Exceptions

  • Compare(String, String)

    Compares two specified String objects and returns an integer that indicates their relative position in the sort order.

    public static int Compare(string strA, string strB)

    Parameters

    • strA

      The first string to compare.

    • strB

      The second string to compare.

    Returns

    • A 32-bit signed integer that indicates the lexical relationship between the two comparands.

      Value

      Condition

      Less than zero

      strA precedes strB in the sort order.

      Zero

      strA occurs in the same position as strB in the sort order.

      Greater than zero

      strA follows strB in the sort order.

  • Compare(String, String, Boolean)

    Compares two specified String objects, ignoring or honoring their case, and returns an integer that indicates their relative position in the sort order.

    public static int Compare(string strA, string strB, bool ignoreCase)

    Parameters

    • strA

      The first string to compare.

    • strB

      The second string to compare.

    • ignoreCase

      true to ignore case during the comparison; otherwise, false.

    Returns

    • A 32-bit signed integer that indicates the lexical relationship between the two comparands.

      Value

      Condition

      Less than zero

      strA precedes strB in the sort order.

      Zero

      strA occurs in the same position as strB in the sort order.

      Greater than zero

      strA follows strB in the sort order.

  • Compare(String, String, StringComparison)

    Compares two specified String objects using the specified rules, and returns an integer that indicates their relative position in the sort order.

    public static int Compare(string strA, string strB, StringComparison comparisonType)

    Parameters

    • strA

      The first string to compare.

    • strB

      The second string to compare.

    • comparisonType

      One of the enumeration values that specifies the rules to use in the comparison.

    Returns

    • A 32-bit signed integer that indicates the lexical relationship between the two comparands.

      Value

      Condition

      Less than zero

      strA precedes strB in the sort order.

      Zero

      strA is in the same position as strB in the sort order.

      Greater than zero

      strA follows strB in the sort order.

    Exceptions

  • CompareOrdinal(String, Int32, String, Int32, Int32)

    Compares substrings of two specified String objects by evaluating the numeric values of the corresponding Char objects in each substring.

    public static int CompareOrdinal(string strA, int indexA, string strB, int indexB, int length)

    Parameters

    • strA

      The first string to use in the comparison.

    • indexA

      The starting index of the substring in strA.

    • strB

      The second string to use in the comparison.

    • indexB

      The starting index of the substring in strB.

    • length

      The maximum number of characters in the substrings to compare.

    Returns

    • A 32-bit signed integer that indicates the lexical relationship between the two comparands.

      Value

      Condition

      Less than zero

      The substring in strA is less than the substring in strB.

      Zero

      The substrings are equal, or length is zero.

      Greater than zero

      The substring in strA is greater than the substring in strB.

    Exceptions

  • CompareOrdinal(String, String)

    Compares two specified String objects by evaluating the numeric values of the corresponding Char objects in each string.

    public static int CompareOrdinal(string strA, string strB)

    Parameters

    • strA

      The first string to compare.

    • strB

      The second string to compare.

    Returns

    • An integer that indicates the lexical relationship between the two comparands.

      Value

      Condition

      Less than zero

      strA is less than strB.

      Zero

      strA and strB are equal.

      Greater than zero

      strA is greater than strB.

  • CompareTo(String)

    Compares this instance with a specified String object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified string.

    public int CompareTo(string strB)

    Parameters

    • strB

      The string to compare with this instance.

    Returns

    • A 32-bit signed integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as the strB parameter.

      Value

      Condition

      Less than zero

      This instance precedes strB.

      Zero

      This instance has the same position in the sort order as strB.

      Greater than zero

      This instance follows strB.

      -or-

      strB is null.

  • Concat(IEnumerable<String>)

    Concatenates the members of a constructed IEnumerable<T> collection of type String.

    [ComVisible(false)]
    public static string Concat(IEnumerable<string> values)

    Parameters

    Returns

    • The concatenated strings in values, or Empty if values is an empty IEnumerable(Of String).

    Exceptions

  • Concat(Object)

    Creates the string representation of a specified object.

    public static string Concat(object arg0)

    Parameters

    • arg0

      The object to represent, or null.

    Returns

    • The string representation of the value of arg0, or Empty if arg0 is null.

  • Concat(Object, Object)

    Concatenates the string representations of two specified objects.

    public static string Concat(object arg0, object arg1)

    Parameters

    • arg0

      The first object to concatenate.

    • arg1

      The second object to concatenate.

    Returns

    • The concatenated string representations of the values of arg0 and arg1.

  • Concat(Object, Object, Object)

    Concatenates the string representations of three specified objects.

    public static string Concat(object arg0, object arg1, object arg2)

    Parameters

    • arg0

      The first object to concatenate.

    • arg1

      The second object to concatenate.

    • arg2

      The third object to concatenate.

    Returns

    • The concatenated string representations of the values of arg0, arg1, and arg2.

  • Concat(Object[])

    Concatenates the string representations of the elements in a specified Object array.

    public static string Concat(params object[] args)

    Parameters

    • args

      An object array that contains the elements to concatenate.

    Returns

    • The concatenated string representations of the values of the elements in args.

    Exceptions

  • Concat(String, String)

    Concatenates two specified instances of String.

    public static string Concat(string str0, string str1)

    Parameters

    • str0

      The first string to concatenate.

    • str1

      The second string to concatenate.

    Returns

    • The concatenation of str0 and str1.

  • Concat(String, String, String)

    Concatenates three specified instances of String.

    public static string Concat(string str0, string str1, string str2)

    Parameters

    • str0

      The first string to concatenate.

    • str1

      The second string to concatenate.

    • str2

      The third string to concatenate.

    Returns

    • The concatenation of str0, str1, and str2.

  • Concat(String, String, String, String)

    Concatenates four specified instances of String.

    public static string Concat(string str0, string str1, string str2, string str3)

    Parameters

    • str0

      The first string to concatenate.

    • str1

      The second string to concatenate.

    • str2

      The third string to concatenate.

    • str3

      The fourth string to concatenate.

    Returns

    • The concatenation of str0, str1, str2, and str3.

  • Concat(String[])

    Concatenates the elements of a specified String array.

    public static string Concat(params string[] values)

    Parameters

    • values

      An array of string instances.

    Returns

    • The concatenated elements of values.

    Exceptions

  • Concat<T>(IEnumerable<T>)

    Concatenates the members of an IEnumerable<T> implementation.

    [ComVisible(false)]
    public static string Concat<T>(IEnumerable<T> values)

    Parameters

    Returns

    • The concatenated members in values.

    Exceptions

  • Contains(String)

    Returns a value indicating whether a specified substring occurs within this string.

    public bool Contains(string value)

    Parameters

    • value

      The string to seek.

    Returns

    • true if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.

    Exceptions

  • CopyTo(Int32, Char[], Int32, Int32)

    Copies a specified number of characters from a specified position in this instance to a specified position in an array of Unicode characters.

    public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)

    Parameters

    • sourceIndex

      The index of the first character in this instance to copy.

    • destination

      An array of Unicode characters to which characters in this instance are copied.

    • destinationIndex

      The index in destination at which the copy operation begins.

    • count

      The number of characters in this instance to copy to destination.

    Exceptions

    • destination is null.

    • sourceIndex, destinationIndex, or count is negative

      -or-

      sourceIndex does not identify a position in the current instance.

      -or-

      destinationIndex does not identify a valid index in the destination array.

      -or-

      count is greater than the length of the substring from startIndex to the end of this instance

      -or-

      count is greater than the length of the subarray from destinationIndex to the end of the destination array.

  • EndsWith(String)

    Determines whether the end of this string instance matches the specified string.

    public bool EndsWith(string value)

    Parameters

    • value

      The string to compare to the substring at the end of this instance.

    Returns

    • true if value matches the end of this instance; otherwise, false.

    Exceptions

  • EndsWith(String, StringComparison)

    Determines whether the end of this string instance matches the specified string when compared using the specified comparison option.

    [ComVisible(false)]
    public bool EndsWith(string value, StringComparison comparisonType)

    Parameters

    • value

      The string to compare to the substring at the end of this instance.

    • comparisonType

      One of the enumeration values that determines how this string and value are compared.

    Returns

    • true if the value parameter matches the end of this string; otherwise, false.

    Exceptions

  • Equals(Object)

    Determines whether this instance and a specified object, which must also be a String object, have the same value.

    public override bool Equals(object obj)

    Parameters

    • obj

      The string to compare to this instance.

    Returns

    • true if obj is a String and its value is the same as this instance; otherwise, false. If obj is null, the method returns false.

    Overrides

  • Equals(String)

    Determines whether this instance and another specified String object have the same value.

    public bool Equals(string value)

    Parameters

    • value

      The string to compare to this instance.

    Returns

    • true if the value of the value parameter is the same as the value of this instance; otherwise, false. If value is null, the method returns false.

  • Equals(String, String)

    Determines whether two specified String objects have the same value.

    public static bool Equals(string a, string b)

    Parameters

    • a

      The first string to compare, or null.

    • b

      The second string to compare, or null.

    Returns

    • true if the value of a is the same as the value of b; otherwise, false. If both a and b are null, the method returns true.

  • Equals(String, String, StringComparison)

    Determines whether two specified String objects have the same value. A parameter specifies the culture, case, and sort rules used in the comparison.

    public static bool Equals(string a, string b, StringComparison comparisonType)

    Parameters

    • a

      The first string to compare, or null.

    • b

      The second string to compare, or null.

    • comparisonType

      One of the enumeration values that specifies the rules for the comparison.

    Returns

    • true if the value of the a parameter is equal to the value of the b parameter; otherwise, false.

    Exceptions

  • Equals(String, StringComparison)

    Determines whether this string and a specified String object have the same value. A parameter specifies the culture, case, and sort rules used in the comparison.

    public bool Equals(string value, StringComparison comparisonType)

    Parameters

    • value

      The string to compare to this instance.

    • comparisonType

      One of the enumeration values that specifies how the strings will be compared.

    Returns

    • true if the value of the value parameter is the same as this string; otherwise, false.

    Exceptions

  • Format(IFormatProvider, String, Object)

    Replaces the format item or items in a specified string with the string representation of the corresponding object. A parameter supplies culture-specific formatting information.

    public static string Format(IFormatProvider provider, string format, object arg0)

    Parameters

    • provider

      An object that supplies culture-specific formatting information.

    • format

      A composite format string.

    • arg0

      The object to format.

    Returns

    • A copy of format in which the format item or items have been replaced by the string representation of arg0.

    Exceptions

  • Format(IFormatProvider, String, Object, Object)

    Replaces the format items in a specified string with the string representation of two specified objects. A parameter supplies culture-specific formatting information.

    public static string Format(IFormatProvider provider, string format, object arg0, object arg1)

    Parameters

    • provider

      An object that supplies culture-specific formatting information.

    • format

      A composite format string.

    • arg0

      The first object to format.

    • arg1

      The second object to format.

    Returns

    • A copy of format in which format items are replaced by the string representations of arg0 and arg1.

    Exceptions

  • Format(IFormatProvider, String, Object, Object, Object)

    Replaces the format items in a specified string with the string representation of three specified objects. An parameter supplies culture-specific formatting information.

    public static string Format(IFormatProvider provider, string format, object arg0, object arg1, object arg2)

    Parameters

    • provider

      An object that supplies culture-specific formatting information.

    • format

      A composite format string.

    • arg0

      The first object to format.

    • arg1

      The second object to format.

    • arg2

      The third object to format.

    Returns

    • A copy of format in which the format items have been replaced by the string representations of arg0, arg1, and arg2.

    Exceptions

    • format, arg0, arg1, or arg2 is null.

    • format is invalid.

      -or-

      The index of a format item is less than zero, or greater than or equal to three.

  • Format(IFormatProvider, String, Object[])

    Replaces the format items in a specified string with the string representations of corresponding objects in a specified array. A parameter supplies culture-specific formatting information.

    public static string Format(IFormatProvider provider, string format, params object[] args)

    Parameters

    • provider

      An object that supplies culture-specific formatting information.

    • format

      A composite format string.

    • args

      An object array that contains zero or more objects to format.

    Returns

    • A copy of format in which the format items have been replaced by the string representation of the corresponding objects in args.

    Exceptions

    • format or args is null.

    • format is invalid.

      -or-

      The index of a format item is less than zero, or greater than or equal to the length of the args array.

  • Format(String, Object)

    Replaces one or more format items in a specified string with the string representation of a specified object.

    public static string Format(string format, object arg0)

    Parameters

    • format

      A composite format string.

    • arg0

      The object to format.

    Returns

    • A copy of format in which any format items are replaced by the string representation of arg0.

    Exceptions

  • Format(String, Object, Object)

    Replaces the format items in a specified string with the string representation of two specified objects.

    public static string Format(string format, object arg0, object arg1)

    Parameters

    • format

      A composite format string.

    • arg0

      The first object to format.

    • arg1

      The second object to format.

    Returns

    • A copy of format in which format items are replaced by the string representations of arg0 and arg1.

    Exceptions

  • Format(String, Object, Object, Object)

    Replaces the format items in a specified string with the string representation of three specified objects.

    public static string Format(string format, object arg0, object arg1, object arg2)

    Parameters

    • format

      A composite format string.

    • arg0

      The first object to format.

    • arg1

      The second object to format.

    • arg2

      The third object to format.

    Returns

    • A copy of format in which the format items have been replaced by the string representations of arg0, arg1, and arg2.

    Exceptions

  • Format(String, Object[])

    Replaces the format item in a specified string with the string representation of a corresponding object in a specified array.

    public static string Format(string format, params object[] args)

    Parameters

    • format

      A composite format string.

    • args

      An object array that contains zero or more objects to format.

    Returns

    • A copy of format in which the format items have been replaced by the string representation of the corresponding objects in args.

    Exceptions

    • format or args is null.

    • format is invalid.

      -or-

      The index of a format item is less than zero, or greater than or equal to the length of the args array.

  • GetHashCode()

    Returns the hash code for this string.

    public override int GetHashCode()

    Returns

    • A 32-bit signed integer hash code.

    Overrides

  • IndexOf(Char)

    Reports the zero-based index of the first occurrence of the specified Unicode character in this string.

    public int IndexOf(char value)

    Parameters

    • value

      A Unicode character to seek.

    Returns

    • The zero-based index position of value if that character is found, or -1 if it is not.

  • IndexOf(Char, Int32)

    Reports the zero-based index of the first occurrence of the specified Unicode character in this string. The search starts at a specified character position.

    public int IndexOf(char value, int startIndex)

    Parameters

    • value

      A Unicode character to seek.

    • startIndex

      The search starting position.

    Returns

    • The zero-based index position of value from the start of the string if that character is found, or -1 if it is not.

    Exceptions

  • IndexOf(Char, Int32, Int32)

    Reports the zero-based index of the first occurrence of the specified character in this instance. The search starts at a specified character position and examines a specified number of character positions.

    public int IndexOf(char value, int startIndex, int count)

    Parameters

    • value

      A Unicode character to seek.

    • startIndex

      The search starting position.

    • count

      The number of character positions to examine.

    Returns

    • The zero-based index position of value from the start of the string if that character is found, or -1 if it is not.

    Exceptions

    • count or startIndex is negative.

      -or-

      startIndex is greater than the length of this string.

      -or-

      count is greater than the length of this string minus startIndex.

  • IndexOf(String)

    Reports the zero-based index of the first occurrence of the specified string in this instance.

    public int IndexOf(string value)

    Parameters

    • value

      The string to seek.

    Returns

    • The zero-based index position of value if that string is found, or -1 if it is not. If value is Empty, the return value is 0.

    Exceptions

  • IndexOf(String, Int32)

    Reports the zero-based index of the first occurrence of the specified string in this instance. The search starts at a specified character position.

    public int IndexOf(string value, int startIndex)

    Parameters

    • value

      The string to seek.

    • startIndex

      The search starting position.

    Returns

    • The zero-based index position of value from the start of the current instance if that string is found, or -1 if it is not. If value is Empty, the return value is startIndex.

    Exceptions

  • IndexOf(String, Int32, Int32)

    Reports the zero-based index of the first occurrence of the specified string in this instance. The search starts at a specified character position and examines a specified number of character positions.

    public int IndexOf(string value, int startIndex, int count)

    Parameters

    • value

      The string to seek.

    • startIndex

      The search starting position.

    • count

      The number of character positions to examine.

    Returns

    • The zero-based index position of value from the start of the current instance if that string is found, or -1 if it is not. If value is Empty, the return value is startIndex.

    Exceptions

  • IndexOf(String, Int32, Int32, StringComparison)

    Reports the zero-based index of the first occurrence of the specified string in the current String object. Parameters specify the starting search position in the current string, the number of characters in the current string to search, and the type of search to use for the specified string.

    public int IndexOf(string value, int startIndex, int count, StringComparison comparisonType)

    Parameters

    • value

      The string to seek.

    • startIndex

      The search starting position.

    • count

      The number of character positions to examine.

    • comparisonType

      One of the enumeration values that specifies the rules for the search.

    Returns

    • The zero-based index position of the value parameter from the start of the current instance if that string is found, or -1 if it is not. If value is Empty, the return value is startIndex.

    Exceptions

  • IndexOf(String, Int32, StringComparison)

    Reports the zero-based index of the first occurrence of the specified string in the current String object. Parameters specify the starting search position in the current string and the type of search to use for the specified string.

    public int IndexOf(string value, int startIndex, StringComparison comparisonType)

    Parameters

    • value

      The string to seek.

    • startIndex

      The search starting position.

    • comparisonType

      One of the enumeration values that specifies the rules for the search.

    Returns

    • The zero-based index position of the value parameter from the start of the current instance if that string is found, or -1 if it is not. If value is Empty, the return value is startIndex.

    Exceptions

  • IndexOf(String, StringComparison)

    Reports the zero-based index of the first occurrence of the specified string in the current String object. A parameter specifies the type of search to use for the specified string.

    public int IndexOf(string value, StringComparison comparisonType)

    Parameters

    • value

      The string to seek.

    • comparisonType

      One of the enumeration values that specifies the rules for the search.

    Returns

    • The index position of the value parameter if that string is found, or -1 if it is not. If value is Empty, the return value is 0.

    Exceptions

  • IndexOfAny(Char[])

    Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters.

    public int IndexOfAny(char[] anyOf)

    Parameters

    • anyOf

      A Unicode character array containing one or more characters to seek.

    Returns

    • The zero-based index position of the first occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found.

    Exceptions

  • IndexOfAny(Char[], Int32)

    Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters. The search starts at a specified character position.

    public int IndexOfAny(char[] anyOf, int startIndex)

    Parameters

    • anyOf

      A Unicode character array containing one or more characters to seek.

    • startIndex

      The search starting position.

    Returns

    • The zero-based index position of the first occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found.

    Exceptions

  • IndexOfAny(Char[], Int32, Int32)

    Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters. The search starts at a specified character position and examines a specified number of character positions.

    public int IndexOfAny(char[] anyOf, int startIndex, int count)

    Parameters

    • anyOf

      A Unicode character array containing one or more characters to seek.

    • startIndex

      The search starting position.

    • count

      The number of character positions to examine.

    Returns

    • The zero-based index position of the first occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found.

    Exceptions

  • Insert(Int32, String)

    Returns a new string in which a specified string is inserted at a specified index position in this instance.

    public string Insert(int startIndex, string value)

    Parameters

    • startIndex

      The zero-based index position of the insertion.

    • value

      The string to insert.

    Returns

    • A new string that is equivalent to this instance, but with value inserted at position startIndex.

    Exceptions

  • IsNullOrEmpty(String)

    Indicates whether the specified string is null or an Empty string.

    public static bool IsNullOrEmpty(string value)

    Parameters

    • value

      The string to test.

    Returns

    • true if the value parameter is null or an empty string (""); otherwise, false.

  • IsNullOrWhiteSpace(String)

    Indicates whether a specified string is null, empty, or consists only of white-space characters.

    public static bool IsNullOrWhiteSpace(string value)

    Parameters

    • value

      The string to test.

    Returns

    • true if the value parameter is null or Empty, or if value consists exclusively of white-space characters.

  • Join(String, IEnumerable<String>)

    Concatenates the members of a constructed IEnumerable<T> collection of type String, using the specified separator between each member.

    [ComVisible(false)]
    public static string Join(string separator, IEnumerable<string> values)

    Parameters

    • separator

      The string to use as a separator.separator is included in the returned string only if values has more than one element.

    • values

      A collection that contains the strings to concatenate.

    Returns

    • A string that consists of the members of values delimited by the separator string. If values has no members, the method returns Empty.

    Exceptions

  • Join(String, Object[])

    Concatenates the elements of an object array, using the specified separator between each element.

    [ComVisible(false)]
    public static string Join(string separator, params object[] values)

    Parameters

    • separator

      The string to use as a separator.separator is included in the returned string only if values has more than one element.

    • values

      An array that contains the elements to concatenate.

    Returns

    • A string that consists of the elements of values delimited by the separator string. If values is an empty array, the method returns Empty.

    Exceptions

  • Join(String, String[])

    Concatenates all the elements of a string array, using the specified separator between each element.

    public static string Join(string separator, params string[] value)

    Parameters

    • separator

      The string to use as a separator. separator is included in the returned string only if value has more than one element.

    • value

      An array that contains the elements to concatenate.

    Returns

    • A string that consists of the elements in value delimited by the separator string. If value is an empty array, the method returns Empty.

    Exceptions

  • Join(String, String[], Int32, Int32)

    Concatenates the specified elements of a string array, using the specified separator between each element.

    public static string Join(string separator, string[] value, int startIndex, int count)

    Parameters

    • separator

      The string to use as a separator. separator is included in the returned string only if value has more than one element.

    • value

      An array that contains the elements to concatenate.

    • startIndex

      The first element in value to use.

    • count

      The number of elements of value to use.

    Returns

    • A string that consists of the strings in value delimited by the separator string.

      -or-

      Empty if count is zero, value has no elements, or separator and all the elements of value are Empty.

    Exceptions

  • Join<T>(String, IEnumerable<T>)

    Concatenates the members of a collection, using the specified separator between each member.

    [ComVisible(false)]
    public static string Join<T>(string separator, IEnumerable<T> values)

    Parameters

    • separator

      The string to use as a separator.separator is included in the returned string only if values has more than one element.

    • values

      A collection that contains the objects to concatenate.

    Returns

    • A string that consists of the members of values delimited by the separator string. If values has no members, the method returns Empty.

    Exceptions

  • LastIndexOf(Char)

    Reports the zero-based index position of the last occurrence of a specified Unicode character within this instance.

    public int LastIndexOf(char value)

    Parameters

    • value

      The Unicode character to seek.

    Returns

    • The zero-based index position of value if that character is found, or -1 if it is not.

  • LastIndexOf(Char, Int32)

    Reports the zero-based index position of the last occurrence of a specified Unicode character within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string.

    public int LastIndexOf(char value, int startIndex)

    Parameters

    • value

      The Unicode character to seek.

    • startIndex

      The starting position of the search. The search proceeds from startIndex toward the beginning of this instance.

    Returns

    • The zero-based index position of value if that character is found, or -1 if it is not found or if the current instance equals Empty.

    Exceptions

    • The current instance does not equal Empty, and startIndex is less than zero or greater than or equal to the length of this instance.

  • LastIndexOf(Char, Int32, Int32)

    Reports the zero-based index position of the last occurrence of the specified Unicode character in a substring within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string for a specified number of character positions.

    public int LastIndexOf(char value, int startIndex, int count)

    Parameters

    • value

      The Unicode character to seek.

    • startIndex

      The starting position of the search. The search proceeds from startIndex toward the beginning of this instance.

    • count

      The number of character positions to examine.

    Returns

    • The zero-based index position of value if that character is found, or -1 if it is not found or if the current instance equals Empty.

    Exceptions

    • The current instance does not equal Empty, and startIndex is less than zero or greater than or equal to the length of this instance.

      -or-

      The current instance does not equal Empty, and startIndex - count + 1 is less than zero.

  • LastIndexOf(String)

    Reports the zero-based index position of the last occurrence of a specified string within this instance.

    public int LastIndexOf(string value)

    Parameters

    • value

      The string to seek.

    Returns

    • The zero-based starting index position of value if that string is found, or -1 if it is not. If value is Empty, the return value is the last index position in this instance.

    Exceptions

  • LastIndexOf(String, Int32)

    Reports the zero-based index position of the last occurrence of a specified string within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string.

    public int LastIndexOf(string value, int startIndex)

    Parameters

    • value

      The string to seek.

    • startIndex

      The search starting position. The search proceeds from startIndex toward the beginning of this instance.

    Returns

    • The zero-based starting index position of value if that string is found, or -1 if it is not found or if the current instance equals Empty. If value is Empty, the return value is the smaller of startIndex and the last index position in this instance.

    Exceptions

  • LastIndexOf(String, Int32, Int32)

    Reports the zero-based index position of the last occurrence of a specified string within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string for a specified number of character positions.

    public int LastIndexOf(string value, int startIndex, int count)

    Parameters

    • value

      The string to seek.

    • startIndex

      The search starting position. The search proceeds from startIndex toward the beginning of this instance.

    • count

      The number of character positions to examine.

    Returns

    • The zero-based starting index position of value if that string is found, or -1 if it is not found or if the current instance equals Empty. If value is Empty, the return value is the smaller of startIndex and the last index position in this instance.

    Exceptions

    • value is null.

    • count is negative.

      -or-

      The current instance does not equal Empty, and startIndex is negative.

      -or-

      The current instance does not equal Empty, and startIndex is greater than the length of this instance.

      -or-

      The current instance does not equal Empty, and startIndex - count+ 1 specifies a position that is not within this instance.

      -or-

      The current instance equals Empty and start is less than -1 or greater than zero.

      -or-

      The current instance equals Empty and count is greater than 1.

  • LastIndexOf(String, Int32, Int32, StringComparison)

    Reports the zero-based index position of the last occurrence of a specified string within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string for the specified number of character positions. A parameter specifies the type of comparison to perform when searching for the specified string.

    public int LastIndexOf(string value, int startIndex, int count, StringComparison comparisonType)

    Parameters

    • value

      The string to seek.

    • startIndex

      The search starting position. The search proceeds from startIndex toward the beginning of this instance.

    • count

      The number of character positions to examine.

    • comparisonType

      One of the enumeration values that specifies the rules for the search.

    Returns

    • The zero-based starting index position of the value parameter if that string is found, or -1 if it is not found or if the current instance equals Empty. If value is Empty, the return value is the smaller of startIndex and the last index position in this instance.

    Exceptions

    • value is null.

    • count is negative.

      -or-

      The current instance does not equal Empty, and startIndex is negative.

      -or-

      The current instance does not equal Empty, and startIndex is greater than the length of this instance.

      -or-

      The current instance does not equal Empty, and startIndex + 1 - count specifies a position that is not within this instance.

      -or-

      The current instance equals Empty and start is less than -1 or greater than zero.

      -or-

      The current instance equals Empty and count is greater than 1.

    • comparisonType is not a valid StringComparison value.

  • LastIndexOf(String, Int32, StringComparison)

    Reports the zero-based index of the last occurrence of a specified string within the current String object. The search starts at a specified character position and proceeds backward toward the beginning of the string. A parameter specifies the type of comparison to perform when searching for the specified string.

    public int LastIndexOf(string value, int startIndex, StringComparison comparisonType)

    Parameters

    • value

      The string to seek.

    • startIndex

      The search starting position. The search proceeds from startIndex toward the beginning of this instance.

    • comparisonType

      One of the enumeration values that specifies the rules for the search.

    Returns

    • The zero-based starting index position of the value parameter if that string is found, or -1 if it is not found or if the current instance equals Empty. If value is Empty, the return value is the smaller of startIndex and the last index position in this instance.

    Exceptions

  • LastIndexOf(String, StringComparison)

    Reports the zero-based index of the last occurrence of a specified string within the current String object. A parameter specifies the type of search to use for the specified string.

    public int LastIndexOf(string value, StringComparison comparisonType)

    Parameters

    • value

      The string to seek.

    • comparisonType

      One of the enumeration values that specifies the rules for the search.

    Returns

    • The zero-based starting index position of the value parameter if that string is found, or -1 if it is not. If value is Empty, the return value is the last index position in this instance.

    Exceptions

  • LastIndexOfAny(Char[])

    Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array.

    public int LastIndexOfAny(char[] anyOf)

    Parameters

    • anyOf

      A Unicode character array containing one or more characters to seek.

    Returns

    • The index position of the last occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found.

    Exceptions

  • LastIndexOfAny(Char[], Int32)

    Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array. The search starts at a specified character position and proceeds backward toward the beginning of the string.

    public int LastIndexOfAny(char[] anyOf, int startIndex)

    Parameters

    • anyOf

      A Unicode character array containing one or more characters to seek.

    • startIndex

      The search starting position. The search proceeds from startIndex toward the beginning of this instance.

    Returns

    • The index position of the last occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found or if the current instance equals Empty.

    Exceptions

  • LastIndexOfAny(Char[], Int32, Int32)

    Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array. The search starts at a specified character position and proceeds backward toward the beginning of the string for a specified number of character positions.

    public int LastIndexOfAny(char[] anyOf, int startIndex, int count)

    Parameters

    • anyOf

      A Unicode character array containing one or more characters to seek.

    • startIndex

      The search starting position. The search proceeds from startIndex toward the beginning of this instance.

    • count

      The number of character positions to examine.

    Returns

    • The index position of the last occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found or if the current instance equals Empty.

    Exceptions

  • PadLeft(Int32)

    Returns a new string that right-aligns the characters in this instance by padding them with spaces on the left, for a specified total length.

    public string PadLeft(int totalWidth)

    Parameters

    • totalWidth

      The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters.

    Returns

    • A new string that is equivalent to this instance, but right-aligned and padded on the left with as many spaces as needed to create a length of totalWidth. However, if totalWidth is less than the length of this instance, the method returns a reference to the existing instance. If totalWidth is equal to the length of this instance, the method returns a new string that is identical to this instance.

    Exceptions

  • PadLeft(Int32, Char)

    Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a specified total length.

    public string PadLeft(int totalWidth, char paddingChar)

    Parameters

    • totalWidth

      The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters.

    • paddingChar

      A Unicode padding character.

    Returns

    • A new string that is equivalent to this instance, but right-aligned and padded on the left with as many paddingChar characters as needed to create a length of totalWidth. However, if totalWidth is less than the length of this instance, the method returns a reference to the existing instance. If totalWidth is equal to the length of this instance, the method returns a new string that is identical to this instance.

    Exceptions

  • PadRight(Int32)

    Returns a new string that left-aligns the characters in this string by padding them with spaces on the right, for a specified total length.

    public string PadRight(int totalWidth)

    Parameters

    • totalWidth

      The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters.

    Returns

    • A new string that is equivalent to this instance, but left-aligned and padded on the right with as many spaces as needed to create a length of totalWidth. However, if totalWidth is less than the length of this instance, the method returns a reference to the existing instance. If totalWidth is equal to the length of this instance, the method returns a new string that is identical to this instance.

    Exceptions

  • PadRight(Int32, Char)

    Returns a new string that left-aligns the characters in this string by padding them on the right with a specified Unicode character, for a specified total length.

    public string PadRight(int totalWidth, char paddingChar)

    Parameters

    • totalWidth

      The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters.

    • paddingChar

      A Unicode padding character.

    Returns

    • A new string that is equivalent to this instance, but left-aligned and padded on the right with as many paddingChar characters as needed to create a length of totalWidth. However, if totalWidth is less than the length of this instance, the method returns a reference to the existing instance. If totalWidth is equal to the length of this instance, the method returns a new string that is identical to this instance.

    Exceptions

  • Remove(Int32)

    Returns a new string in which all the characters in the current instance, beginning at a specified position and continuing through the last position, have been deleted.

    public string Remove(int startIndex)

    Parameters

    • startIndex

      The zero-based position to begin deleting characters.

    Returns

    • A new string that is equivalent to this string except for the removed characters.

    Exceptions

  • Remove(Int32, Int32)

    Returns a new string in which a specified number of characters in the current instance beginning at a specified position have been deleted.

    public string Remove(int startIndex, int count)

    Parameters

    • startIndex

      The zero-based position to begin deleting characters.

    • count

      The number of characters to delete.

    Returns

    • A new string that is equivalent to this instance except for the removed characters.

    Exceptions

    • Either startIndex or count is less than zero.

      -or-

      startIndex plus count specify a position outside this instance.

  • Replace(Char, Char)

    Returns a new string in which all occurrences of a specified Unicode character in this instance are replaced with another specified Unicode character.

    public string Replace(char oldChar, char newChar)

    Parameters

    • oldChar

      The Unicode character to be replaced.

    • newChar

      The Unicode character to replace all occurrences of oldChar.

    Returns

    • A string that is equivalent to this instance except that all instances of oldChar are replaced with newChar. If oldChar is not found in the current instance, the method returns the current instance unchanged.

  • Replace(String, String)

    Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string.

    public string Replace(string oldValue, string newValue)

    Parameters

    • oldValue

      The string to be replaced.

    • newValue

      The string to replace all occurrences of oldValue.

    Returns

    • A string that is equivalent to the current string except that all instances of oldValue are replaced with newValue. If oldValue is not found in the current instance, the method returns the current instance unchanged.

    Exceptions

  • Split(Char[])

    Splits a string into substrings that are based on the characters in an array.

    public string[] Split(params char[] separator)

    Parameters

    • separator

      A character array that delimits the substrings in this string, an empty array that contains no delimiters, or null.

    Returns

    • An array whose elements contain the substrings from this instance that are delimited by one or more characters in separator. For more information, see the Remarks section.

  • Split(Char[], Int32)

    Splits a string into a maximum number of substrings based on the characters in an array. You also specify the maximum number of substrings to return.

    public string[] Split(char[] separator, int count)

    Parameters

    • separator

      A character array that delimits the substrings in this string, an empty array that contains no delimiters, or null.

    • count

      The maximum number of substrings to return.

    Returns

    • An array whose elements contain the substrings in this instance that are delimited by one or more characters in separator. For more information, see the Remarks section.

    Exceptions

  • Split(Char[], Int32, StringSplitOptions)

    Splits a string into a maximum number of substrings based on the characters in an array.

    [ComVisible(false)]
    public string[] Split(char[] separator, int count, StringSplitOptions options)

    Parameters

    • separator

      A character array that delimits the substrings in this string, an empty array that contains no delimiters, or null.

    • count

      The maximum number of substrings to return.

    • options

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

    Returns

    • An array whose elements contain the substrings in this string that are delimited by one or more characters in separator. For more information, see the Remarks section.

    Exceptions

  • Split(Char[], StringSplitOptions)

    Splits a string into substrings based on the characters in an array. You can specify whether the substrings include empty array elements.

    [ComVisible(false)]
    public string[] Split(char[] separator, StringSplitOptions options)

    Parameters

    • separator

      A character array that delimits the substrings in this string, an empty array that contains no delimiters, or null.

    • options

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

    Returns

    • An array whose elements contain the substrings in this string that are delimited by one or more characters in separator. For more information, see the Remarks section.

    Exceptions

  • Split(String[], Int32, StringSplitOptions)

    Splits a string into a maximum number of substrings based on the strings in an array. You can specify whether the substrings include empty array elements.

    [ComVisible(false)]
    public string[] Split(string[] separator, int count, StringSplitOptions options)

    Parameters

    • separator

      A string array that delimits the substrings in this string, an empty array that contains no delimiters, or null.

    • count

      The maximum number of substrings to return.

    • options

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

    Returns

    • An array whose elements contain the substrings in this string that are delimited by one or more strings in separator. For more information, see the Remarks section.

    Exceptions

  • Split(String[], StringSplitOptions)

    Splits a string into substrings based on the strings in an array. You can specify whether the substrings include empty array elements.

    [ComVisible(false)]
    public string[] Split(string[] separator, StringSplitOptions options)

    Parameters

    • separator

      A string array that delimits the substrings in this string, an empty array that contains no delimiters, or null.

    • options

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

    Returns

    • An array whose elements contain the substrings in this string that are delimited by one or more strings in separator. For more information, see the Remarks section.

    Exceptions

  • StartsWith(String)

    Determines whether the beginning of this string instance matches the specified string.

    public bool StartsWith(string value)

    Parameters

    • value

      The string to compare.

    Returns

    • true if value matches the beginning of this string; otherwise, false.

    Exceptions

  • StartsWith(String, StringComparison)

    Determines whether the beginning of this string instance matches the specified string when compared using the specified comparison option.

    [ComVisible(false)]
    public bool StartsWith(string value, StringComparison comparisonType)

    Parameters

    • value

      The string to compare.

    • comparisonType

      One of the enumeration values that determines how this string and value are compared.

    Returns

    • true if this instance begins with value; otherwise, false.

    Exceptions

  • Substring(Int32)

    Retrieves a substring from this instance. The substring starts at a specified character position and continues to the end of the string.

    public string Substring(int startIndex)

    Parameters

    • startIndex

      The zero-based starting character position of a substring in this instance.

    Returns

    • A string that is equivalent to the substring that begins at startIndex in this instance, or Empty if startIndex is equal to the length of this instance.

    Exceptions

  • Substring(Int32, Int32)

    Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.

    public string Substring(int startIndex, int length)

    Parameters

    • startIndex

      The zero-based starting character position of a substring in this instance.

    • length

      The number of characters in the substring.

    Returns

    • A string that is equivalent to the substring of length length that begins at startIndex in this instance, or Empty if startIndex is equal to the length of this instance and length is zero.

    Exceptions

    • startIndex plus length indicates a position not within this instance.

      -or-

      startIndex or length is less than zero.

  • ToCharArray()

    Copies the characters in this instance to a Unicode character array.

    public char[] ToCharArray()

    Returns

    • A Unicode character array whose elements are the individual characters of this instance. If this instance is an empty string, the returned array is empty and has a zero length.

  • ToCharArray(Int32, Int32)

    Copies the characters in a specified substring in this instance to a Unicode character array.

    public char[] ToCharArray(int startIndex, int length)

    Parameters

    • startIndex

      The starting position of a substring in this instance.

    • length

      The length of the substring in this instance.

    Returns

    • A Unicode character array whose elements are the length number of characters in this instance starting from character position startIndex.

    Exceptions

    • startIndex or length is less than zero.

      -or-

      startIndex plus length is greater than the length of this instance.

  • ToLower()

    Returns a copy of this string converted to lowercase.

    public string ToLower()

    Returns

    • A string in lowercase.

  • ToLowerInvariant()

    Returns a copy of this String object converted to lowercase using the casing rules of the invariant culture.

    public string ToLowerInvariant()

    Returns

    • The lowercase equivalent of the current string.

  • ToString()

    Returns this instance of String; no actual conversion is performed.

    public override string ToString()

    Returns

    Overrides

  • ToUpper()

    Returns a copy of this string converted to uppercase.

    public string ToUpper()

    Returns

    • The uppercase equivalent of the current string.

  • ToUpperInvariant()

    Returns a copy of this String object converted to uppercase using the casing rules of the invariant culture.

    public string ToUpperInvariant()

    Returns

    • The uppercase equivalent of the current string.

  • Trim()

    Removes all leading and trailing white-space characters from the current String object.

    public string Trim()

    Returns

    • The string that remains after all white-space characters are removed from the start and end of the current string. If no characters can be trimmed from the current instance, the method returns the current instance unchanged.

  • Trim(Char[])

    Removes all leading and trailing occurrences of a set of characters specified in an array from the current String object.

    public string Trim(params char[] trimChars)

    Parameters

    • trimChars

      An array of Unicode characters to remove, or null.

    Returns

    • The string that remains after all occurrences of the characters in the trimChars parameter are removed from the start and end of the current string. If trimChars is null or an empty array, white-space characters are removed instead. If no characters can be trimmed from the current instance, the method returns the current instance unchanged.

  • TrimEnd(Char[])

    Removes all trailing occurrences of a set of characters specified in an array from the current String object.

    public string TrimEnd(params char[] trimChars)

    Parameters

    • trimChars

      An array of Unicode characters to remove, or null.

    Returns

    • The string that remains after all occurrences of the characters in the trimChars parameter are removed from the end of the current string. If trimChars is null or an empty array, Unicode white-space characters are removed instead. If no characters can be trimmed from the current instance, the method returns the current instance unchanged.

  • TrimStart(Char[])

    Removes all leading occurrences of a set of characters specified in an array from the current String object.

    public string TrimStart(params char[] trimChars)

    Parameters

    • trimChars

      An array of Unicode characters to remove, or null.

    Returns

    • The string that remains after all occurrences of characters in the trimChars parameter are removed from the start of the current string. If trimChars is null or an empty array, white-space characters are removed instead.

Operators

  • Equality(String, String)

    Determines whether two specified strings have the same value.

    public static bool operator ==(string a, string b)

    Parameters

    • a

      The first string to compare, or null.

    • b

      The second string to compare, or null.

    Returns

    • true if the value of a is the same as the value of b; otherwise, false.

  • Inequality(String, String)

    Determines whether two specified strings have different values.

    public static bool operator !=(string a, string b)

    Parameters

    • a

      The first string to compare, or null.

    • b

      The second string to compare, or null.

    Returns

    • true if the value of a is different from the value of b; otherwise, false.

Explicit Interface Implementations

  • IEnumerable.GetEnumerator()

    Returns an enumerator that iterates through the current String object.

    IEnumerator IEnumerable.GetEnumerator()

    Returns

    • An enumerator that can be used to iterate through the current string.

  • IComparable.CompareTo(Object)
    int IComparable.CompareTo(object value)

    Parameters

    Returns

  • IConvertible.GetTypeCode()
    TypeCode IConvertible.GetTypeCode()

    Returns

  • IConvertible.ToBoolean(IFormatProvider)

    For a description of this member, see ToBoolean(IFormatProvider).

    bool IConvertible.ToBoolean(IFormatProvider provider)

    Parameters

    Returns

    Exceptions

  • IConvertible.ToByte(IFormatProvider)

    For a description of this member, see ToByte(IFormatProvider).

    byte IConvertible.ToByte(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

    • The converted value of the current String object.

    Exceptions

  • IConvertible.ToChar(IFormatProvider)

    For a description of this member, see ToChar(IFormatProvider).

    char IConvertible.ToChar(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

    • The character at index 0 in the current String object.

  • IConvertible.ToDateTime(IFormatProvider)

    For a description of this member, see ToDateTime(IFormatProvider).

    DateTime IConvertible.ToDateTime(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

  • IConvertible.ToDecimal(IFormatProvider)

    For a description of this member, see ToDecimal(IFormatProvider).

    decimal IConvertible.ToDecimal(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

    Exceptions

  • IConvertible.ToDouble(IFormatProvider)

    For a description of this member, see ToDouble(IFormatProvider).

    double IConvertible.ToDouble(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

    Exceptions

  • IConvertible.ToInt16(IFormatProvider)

    For a description of this member, see ToInt16(IFormatProvider).

    short IConvertible.ToInt16(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

    • The converted value of the current String object.

    Exceptions

  • IConvertible.ToInt32(IFormatProvider)

    For a description of this member, see ToInt32(IFormatProvider).

    int IConvertible.ToInt32(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

    • The converted value of the current String object.

  • IConvertible.ToInt64(IFormatProvider)

    For a description of this member, see ToInt64(IFormatProvider).

    long IConvertible.ToInt64(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

    • The converted value of the current String object.

  • IConvertible.ToSByte(IFormatProvider)

    For a description of this member, see ToSByte(IFormatProvider).

    sbyte IConvertible.ToSByte(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

    • The converted value of the current String object.

    Exceptions

  • IConvertible.ToSingle(IFormatProvider)

    For a description of this member, see ToSingle(IFormatProvider).

    float IConvertible.ToSingle(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

  • IConvertible.ToString(IFormatProvider)
    string IConvertible.ToString(IFormatProvider provider)

    Parameters

    Returns

  • IConvertible.ToType(Type, IFormatProvider)

    For a description of this member, see ToType(Type, IFormatProvider).

    object IConvertible.ToType(Type type, IFormatProvider provider)

    Parameters

    • type

      The type of the returned object.

    • provider

      An object that provides culture-specific formatting information.

    Returns

    Exceptions

  • IConvertible.ToUInt16(IFormatProvider)

    For a description of this member, see ToUInt16(IFormatProvider).

    ushort IConvertible.ToUInt16(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

    Exceptions

  • IConvertible.ToUInt32(IFormatProvider)

    For a description of this member, see ToUInt32(IFormatProvider).

    uint IConvertible.ToUInt32(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

    Exceptions

  • IConvertible.ToUInt64(IFormatProvider)

    For a description of this member, see ToUInt64(IFormatProvider).

    ulong IConvertible.ToUInt64(IFormatProvider provider)

    Parameters

    • provider

      An object that provides culture-specific formatting information.

    Returns

Details

Namespace

System

Assembly

System.Runtime.dll

See Also