Duration (Pacific Standard Time):
To (Pacific Standard Time):
Impact:
  • None
User Action:
  • None
 Collapse AllExpand All      Code: All Code: Multiple Code: Visual Basic Code: C# Code: Visual C++ Code: F# Code: JScript 

String Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Represents text as a series of Unicode characters.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
<SerializableAttribute> _
Public NotInheritable Class String _
	Implements IComparable

The String type exposes the following members.

  Name Description
Public method String(array<Char>[]()[][]) Initializes a new instance of the String class to the value indicated by an array of Unicode characters.
Public method 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 method String(array<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.
Top
  Name Description
Public property Chars Gets the Char object at a specified position in the current String object.
Public property Length Gets the number of characters in the current String object.
Top
  Name Description
Public method Static member Compare Compares two specified String objects and returns an integer that indicates their relative position in the sort order.
Public method CompareTo(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 method 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 method Static member Concat(Object) Creates the string representation of a specified object.
Public method Static member Concat(array<Object>[]()[][]) Concatenates the string representations of the elements in a specified Object array.
Public method Static member Concat(array<String>[]()[][]) Concatenates the elements of a specified String array.
Public method Static member Concat(Object, Object) Concatenates the string representations of two specified objects.
Public method Static member Concat(String, String) Concatenates two specified instances of String.
Public method Static member Concat(Object, Object, Object) Concatenates the string representations of three specified objects.
Public method Static member Concat(String, String, String) Concatenates three specified instances of String.
Public method Static member Concat(String, String, String, String) Concatenates four specified instances of String.
Public method Equals(Object) Determines whether this instance and a specified object, which must also be a String object, have the same value. (Overrides Object..::..Equals(Object).)
Public method Static member Equals(String, String) Determines whether two specified String objects have the same value.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IndexOf(Char) Reports the zero-based index of the first occurrence of the specified Unicode character in this string.
Public method IndexOf(String) Reports the zero-based index of the first occurrence of the specified string in this instance.
Public method 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 method 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 method 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 method 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 method IndexOfAny(array<Char>[]()[][]) Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters.
Public method IndexOfAny(array<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 method IndexOfAny(array<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 method Static member Intern Retrieves the system's reference to the specified String.
Public method Static member IsInterned Retrieves a reference to a specified String.
Public method LastIndexOf(Char) Reports the zero-based index position of the last occurrence of a specified Unicode character within this instance.
Public method LastIndexOf(String) Reports the zero-based index position of the last occurrence of a specified string within this instance.
Public method 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 method 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 method 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 method 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 method LastIndexOfAny(array<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 method LastIndexOfAny(array<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 method LastIndexOfAny(array<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 method Split(array<Char>[]()[][]) Returns a string array that contains the substrings in this instance that are delimited by elements of a specified Unicode character array.
Public method Split(array<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 method Substring(Int32) Retrieves a substring from this instance. The substring starts at a specified character position.
Public method Substring(Int32, Int32) Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.
Public method ToCharArray()()()() Copies the characters in this instance to a Unicode character array.
Public method ToCharArray(Int32, Int32) Copies the characters in a specified substring in this instance to a Unicode character array.
Public method ToLower Returns a copy of this string converted to lowercase.
Public method ToString Returns this instance of String; no actual conversion is performed. (Overrides Object..::..ToString()()()().)
Public method ToUpper Returns a copy of this string converted to uppercase.
Public method Trim()()()() Removes all leading and trailing white-space characters from the current String object.
Public method Trim(array<Char>[]()[][]) Removes all leading and trailing occurrences of a set of characters specified in an array from the current String object.
Public method TrimEnd Removes all trailing occurrences of a set of characters specified in an array from the current String object.
Public method TrimStart Removes all leading occurrences of a set of characters specified in an array from the current String object.
Top
  Name Description
Public operator Static member Equality Determines whether two specified strings have the same value.
Public operator Static member Inequality Determines whether two specified strings have different values.
Top
  Name Description
Public field Static member Empty Represents the empty string. This field is read-only.
Top

A string is a sequential collection of Unicode characters that is used to represent text. A String object is a sequential collection of System..::..Char objects that represent a string. The value of the String object is the content of the sequential collection, and that value is immutable (that is, it is read-only).

This type is thread safe.