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.
Inheritance Hierarchy
System. . :: . .Object
System..::..String
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<SerializableAttribute> _
Public NotInheritable Class String _
Implements IComparable
[SerializableAttribute]
public sealed class String : IComparable
[SerializableAttribute]
public ref class String sealed : IComparable
[<Sealed>]
[<SerializableAttribute>]
type String =
class
interface IComparable
end
public final class String implements IComparable
The String type exposes the following members.
Constructors
Name | Description | |
---|---|---|
String(array<Char> [] () [] []) | Initializes a new instance of the String class to the value indicated by an array of Unicode characters. | |
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. | |
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
Properties
Name | Description | |
---|---|---|
Chars | Gets the Char object at a specified position in the current String object. | |
Length | Gets the number of characters in the current String object. |
Top
Methods
Name | Description | |
---|---|---|
Compare | Compares two specified String objects and returns an integer that indicates their relative position in the sort order. | |
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. | |
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. | |
Concat(Object) | Creates the string representation of a specified object. | |
Concat(array<Object> [] () [] []) | Concatenates the string representations of the elements in a specified Object array. | |
Concat(array<String> [] () [] []) | Concatenates the elements of a specified String array. | |
Concat(Object, Object) | Concatenates the string representations of two specified objects. | |
Concat(String, String) | Concatenates two specified instances of String. | |
Concat(Object, Object, Object) | Concatenates the string representations of three specified objects. | |
Concat(String, String, String) | Concatenates three specified instances of String. | |
Concat(String, String, String, String) | Concatenates four specified instances of String. | |
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).) | |
Equals(String, String) | Determines whether two specified String objects have the same value. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
IndexOf(Char) | Reports the zero-based index of the first occurrence of the specified Unicode character in this string. | |
IndexOf(String) | Reports the zero-based index of the first occurrence of the specified string in this instance. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
Intern | Retrieves the system's reference to the specified String. | |
IsInterned | Retrieves a reference to a specified String. | |
LastIndexOf(Char) | Reports the zero-based index position of the last occurrence of a specified Unicode character within this instance. | |
LastIndexOf(String) | Reports the zero-based index position of the last occurrence of a specified string within this instance. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
Substring(Int32) | Retrieves a substring from this instance. The substring starts at a specified character position. | |
Substring(Int32, Int32) | Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length. | |
ToCharArray() () () () | Copies the characters in this instance to a Unicode character array. | |
ToCharArray(Int32, Int32) | Copies the characters in a specified substring in this instance to a Unicode character array. | |
ToLower | Returns a copy of this string converted to lowercase. | |
ToString | Returns this instance of String; no actual conversion is performed. (Overrides Object. . :: . .ToString() () () ().) | |
ToUpper | Returns a copy of this string converted to uppercase. | |
Trim() () () () | Removes all leading and trailing white-space characters from the current String object. | |
Trim(array<Char> [] () [] []) | Removes all leading and trailing occurrences of a set of characters specified in an array from the current String object. | |
TrimEnd | Removes all trailing occurrences of a set of characters specified in an array from the current String object. | |
TrimStart | Removes all leading occurrences of a set of characters specified in an array from the current String object. |
Top
Operators
Name | Description | |
---|---|---|
Equality | Determines whether two specified strings have the same value. | |
Inequality | Determines whether two specified strings have different values. |
Top
Fields
Name | Description | |
---|---|---|
Empty | Represents the empty string. This field is read-only. |
Top
Remarks
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).
Thread Safety
This type is thread safe.