Click or drag to resize
String Class
Represents text as a series of Unicode characters.
Inheritance Hierarchy
SystemObject
  SystemString

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
[SerializableAttribute]
public sealed class String : IComparable, 
	ICloneable, IConvertible, IComparable<string>, IEnumerable<char>, 
	IEnumerable, IEquatable<string>

The String type exposes the following members.

Methods
  NameDescription
Public methodStatic memberCompare(String, String)
Compares two specified String objects and returns an integer that indicates their relative position in the sort order.
Public methodStatic memberCompare(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 methodStatic memberCompare(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 methodStatic memberCompare(String, String, Boolean, CultureInfo)
Compares two specified String objects, ignoring or honoring their case, and using culture-specific information to influence the comparison, and returns an integer that indicates their relative position in the sort order.
Public methodStatic memberCompare(String, String, CultureInfo, CompareOptions)
Compares two specified String objects using the specified comparison options and culture-specific information to influence the comparison, and returns an integer that indicates the relationship of the two strings to each other in the sort order.
Public methodStatic memberCompare(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 methodStatic memberCompare(String, Int32, String, Int32, Int32, Boolean)
Compares substrings of two specified String objects, ignoring or honoring their case, and returns an integer that indicates their relative position in the sort order.
Public methodStatic memberCompare(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 methodStatic memberCompare(String, Int32, String, Int32, Int32, Boolean, CultureInfo)
Compares substrings of two specified String objects, ignoring or honoring their case and using culture-specific information to influence the comparison, and returns an integer that indicates their relative position in the sort order.
Public methodStatic memberCompare(String, Int32, String, Int32, Int32, CultureInfo, CompareOptions)
Compares substrings of two specified String objects using the specified comparison options and culture-specific information to influence the comparison, and returns an integer that indicates the relationship of the two substrings to each other in the sort order.
Public methodCompareTo(Object)
Compares this instance with a specified Object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified Object.
Public methodCompareTo(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 methodStatic memberConcat(Object)
Creates the string representation of a specified object.
Public methodStatic memberConcat(Object)
Concatenates the string representations of the elements in a specified Object array.
Public methodStatic memberConcat(IEnumerableString)
Public methodStatic memberConcat(String)
Concatenates the elements of a specified String array.
Public methodStatic memberConcat(Object, Object)
Concatenates the string representations of two specified objects.
Public methodStatic memberConcat(String, String)
Concatenates two specified instances of String.
Public methodStatic memberConcat(Object, Object, Object)
Concatenates the string representations of three specified objects.
Public methodStatic memberConcat(String, String, String)
Concatenates three specified instances of String.
Public methodStatic memberConcat(Object, Object, Object, Object)
Concatenates the string representations of four specified objects and any objects specified in an optional variable length parameter list.
Public methodStatic memberConcat(String, String, String, String)
Concatenates four specified instances of String.
Public methodStatic memberConcatT(IEnumerableT)
Public methodContains
Returns a value indicating whether the specified String object occurs within this string.
Public methodCopyTo
Copies a specified number of characters from a specified position in this instance to a specified position in an array of Unicode characters.
Public methodEndsWith(String)
Determines whether the end of this string instance matches the specified string.
Public methodEndsWith(String, StringComparison)
Determines whether the end of this string instance matches the specified string when compared using the specified comparison option.
Public methodEndsWith(String, Boolean, CultureInfo)
Determines whether the end of this string instance matches the specified string when compared using the specified culture.
Public methodEquals(Object)
Determines whether this instance and a specified object, which must also be a String object, have the same value.
(Overrides ObjectEquals(Object).)
Public methodEquals(String)
Determines whether this instance and another specified String object have the same value.
Public methodStatic memberEquals(String, String)
Determines whether two specified String objects have the same value.
Public methodEquals(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 methodStatic memberEquals(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 methodStatic memberFormat(String, Object)
Replaces one or more format items in a specified string with the string representation of a specified object.
Public methodStatic memberFormat(String, Object)
Replaces the format item in a specified string with the string representation of a corresponding object in a specified array.
Public methodStatic memberFormat(IFormatProvider, String, Object)
Replaces the format item in a specified string with the string representation of a corresponding object in a specified array. A specified parameter supplies culture-specific formatting information.
Public methodStatic memberFormat(String, Object, Object)
Replaces the format items in a specified string with the string representation of two specified objects.
Public methodStatic memberFormat(String, Object, Object, Object)
Replaces the format items in a specified string with the string representation of three specified objects.
Public methodGetHashCode
Returns the hash code for this string.
(Overrides ObjectGetHashCode.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIndexOf(Char)
Reports the zero-based index of the first occurrence of the specified Unicode character in this string.
Public methodIndexOf(String)
Reports the zero-based index of the first occurrence of the specified string in this instance.
Public methodIndexOf(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 methodIndexOf(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 methodIndexOf(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 methodIndexOf(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 methodIndexOf(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 methodIndexOf(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 methodIndexOf(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 methodIndexOfAny(Char)
Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters.
Public methodIndexOfAny(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 methodIndexOfAny(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 methodStatic memberIsNullOrEmpty
Indicates whether the specified string is null or an Empty string.
Public methodStatic memberIsNullOrWhiteSpace
Indicates whether a specified string is null, empty, or consists only of white-space characters.
Public methodStatic memberJoin(String, IEnumerableString)
Concatenates the members of a constructed IEnumerableT collection of type String, using the specified separator between each member.
Public methodStatic memberJoin(String, Object)
Concatenates the elements of an object array, using the specified separator between each element.
Public methodStatic memberJoin(String, String)
Concatenates all the elements of a string array, using the specified separator between each element.
Public methodStatic memberJoin(String, String, Int32, Int32)
Concatenates the specified elements of a string array, using the specified separator between each element.
Public methodStatic memberJoinT(String, IEnumerableT)
Concatenates the members of a collection, using the specified separator between each member.
Public methodLastIndexOf(Char)
Reports the zero-based index position of the last occurrence of a specified Unicode character within this instance.
Public methodLastIndexOf(String)
Reports the zero-based index position of the last occurrence of a specified string within this instance.
Public methodLastIndexOf(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.
Public methodLastIndexOf(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.
Public methodLastIndexOf(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 methodLastIndexOf(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 examines a specified number of character positions.
Public methodLastIndexOf(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 examines a specified number of character positions.
Public methodLastIndexOf(String, Int32, StringComparison)
Reports the zero-based index of the last occurrence of a specified string within the current String object. Parameters specify the starting search position in the current string, and type of search to use for the specified string.
Public methodLastIndexOf(String, Int32, Int32, StringComparison)
Reports the zero-based index position of the last occurrence of a specified string within this instance. 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 methodLastIndexOfAny(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 methodLastIndexOfAny(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.
Public methodLastIndexOfAny(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 examines a specified number of character positions.
Public methodNormalize
Returns a new string whose textual value is the same as this string, but whose binary representation is in Unicode normalization form C.
Public methodNormalize(NormalizationForm)
Returns a new string whose textual value is the same as this string, but whose binary representation is in the specified Unicode normalization form.
Public methodPadLeft(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 methodPadLeft(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 methodPadRight(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 methodPadRight(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 methodRemove(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 methodRemove(Int32, Int32)
Returns a new string in which a specified number of characters in this instance beginning at a specified position have been deleted.
Public methodReplace(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 methodReplace(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 methodSplit(Char)
Returns a string array that contains the substrings in this instance that are delimited by elements of a specified Unicode character array.
Public methodSplit(Char, Int32)
Returns a string array that contains the substrings in this instance that are delimited by elements of a specified Unicode character array. A parameter specifies the maximum number of substrings to return.
Public methodSplit(Char, StringSplitOptions)
Returns a string array that contains the substrings in this string that are delimited by elements of a specified Unicode character array. A parameter specifies whether to return empty array elements.
Public methodSplit(String, StringSplitOptions)
Returns a string array that contains the substrings in this string that are delimited by elements of a specified string array. A parameter specifies whether to return empty array elements.
Public methodSplit(Char, Int32, StringSplitOptions)
Returns a string array that contains the substrings in this string that are delimited by elements of a specified Unicode character array. Parameters specify the maximum number of substrings to return and whether to return empty array elements.
Public methodSplit(String, Int32, StringSplitOptions)
Returns a string array that contains the substrings in this string that are delimited by elements of a specified string array. Parameters specify the maximum number of substrings to return and whether to return empty array elements.
Public methodStartsWith(String)
Determines whether the beginning of this string instance matches the specified string.
Public methodStartsWith(String, StringComparison)
Determines whether the beginning of this string instance matches the specified string when compared using the specified comparison option.
Public methodStartsWith(String, Boolean, CultureInfo)
Determines whether the beginning of this string instance matches the specified string when compared using the specified culture.
Public methodSubstring(Int32)
Retrieves a substring from this instance. The substring starts at a specified character position.
Public methodSubstring(Int32, Int32)
Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.
Public methodToCharArray
Copies the characters in this instance to a Unicode character array.
Public methodToCharArray(Int32, Int32)
Copies the characters in a specified substring in this instance to a Unicode character array.
Public methodToLower
Returns a copy of this string converted to lowercase.
Public methodToLower(CultureInfo)
Returns a copy of this string converted to lowercase, using the casing rules of the specified culture.
Public methodToLowerInvariant
Returns a copy of this String object converted to lowercase using the casing rules of the invariant culture.
Public methodToString
Returns this instance of String; no actual conversion is performed.
(Overrides ObjectToString.)
Public methodToString(IFormatProvider)
Returns this instance of String; no actual conversion is performed.
Public methodToUpper
Returns a copy of this string converted to uppercase.
Public methodToUpper(CultureInfo)
Returns a copy of this string converted to uppercase, using the casing rules of the specified culture.
Public methodToUpperInvariant
Returns a copy of this String object converted to uppercase using the casing rules of the invariant culture.
Public methodTrim
Removes all leading and trailing white-space characters from the current String object.
Public methodTrim(Char)
Removes all leading and trailing occurrences of a set of characters specified in an array from the current String object.
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Determines whether two specified strings have the same value.
Public operatorStatic memberInequality
Determines whether two specified strings have different values.
Top
Fields
  NameDescription
Public fieldStatic memberEmpty
Represents the empty string. This field is read-only.
Top
Properties
  NameDescription
Public propertyLength
Gets the number of characters in the current String object.
Top
See Also