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
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

Properties

  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

Methods

  Name Description
Public methodStatic 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 methodStatic member Concat(Object) Creates the string representation of a specified object.
Public methodStatic member Concat(array<Object> [] () [] []) Concatenates the string representations of the elements in a specified Object array.
Public methodStatic member Concat(array<String> [] () [] []) Concatenates the elements of a specified String array.
Public methodStatic member Concat(Object, Object) Concatenates the string representations of two specified objects.
Public methodStatic member Concat(String, String) Concatenates two specified instances of String.
Public methodStatic member Concat(Object, Object, Object) Concatenates the string representations of three specified objects.
Public methodStatic member Concat(String, String, String) Concatenates three specified instances of String.
Public methodStatic 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 methodStatic 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 methodStatic member Intern Retrieves the system's reference to the specified String.
Public methodStatic 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

Operators

  Name Description
Public operatorStatic member Equality Determines whether two specified strings have the same value.
Public operatorStatic member Inequality Determines whether two specified strings have different values.

Top

Fields

  Name Description
Public fieldStatic member 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.

See Also

Reference

System Namespace