Namespace: System
String
Represents text as a sequence of UTF-16 code units.
Properties (2)
int Length
Gets the number of characters in the current String object.
Value: The number of characters in the current string.
char Chars(Int32)
Gets the Char object at a specified position in the current String object.
Value: The object at position index.
Methods (20)
String Format(String,Object[])
Replaces the format item in a specified string with the string representation of a corresponding object in a specified array.
| Parameter | Description |
|---|---|
| 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.
String Concat(Object[])
Concatenates the string representations of the elements in a specified Object array.
| Parameter | Description |
|---|---|
| args | An object array that contains the elements to concatenate. |
Returns: The concatenated string representations of the values of the elements in args.
String Join(String,Object[])
Concatenates the elements of an object array, using the specified separator between each element.
| Parameter | Description |
|---|---|
| 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.
int 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.
| Parameter | Description |
|---|---|
| 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.
String(Char*)Constructor
Initializes a new instance of the String class to the value indicated by a specified pointer to an array of Unicode characters.
| Parameter | Description |
|---|---|
| value | A pointer to a null-terminated array of Unicode characters. |
char[] ToCharArray
Copies the characters in this instance to a Unicode character array.
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.
int 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.
| Parameter | Description |
|---|---|
| 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.
int LastIndexOf(String)
Reports the zero-based index position of the last occurrence of a specified string within this instance.
| Parameter | Description |
|---|---|
| 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.
bool Contains(String)
Returns a value indicating whether a specified substring occurs within this string.
| Parameter | Description |
|---|---|
| value | The string to seek. |
Returns: true if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.
bool StartsWith(String)
Determines whether the beginning of this string instance matches the specified string.
| Parameter | Description |
|---|---|
| value | The string to compare. |
Returns: true if value matches the beginning of this string; otherwise, false.
bool EndsWith(String)
Determines whether the end of this string instance matches the specified string.
| Parameter | Description |
|---|---|
| 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.
String Substring(Int32,Int32)
Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.
| Parameter | Description |
|---|---|
| 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.
String Substring(Int32)
Retrieves a substring from this instance. The substring starts at a specified character position and continues to the end of the string.
| Parameter | Description |
|---|---|
| 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.
String ToLower
Returns a copy of this string converted to lowercase.
Returns: A string in lowercase.
String ToUpper
Returns a copy of this string converted to uppercase.
Returns: The uppercase equivalent of the current string.
String 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.
| Parameter | Description |
|---|---|
| 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.
String Trim
Removes all leading and trailing white-space characters from the current String object.
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.
int 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.
| Parameter | Description |
|---|---|
| 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.
String[] 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.
| Parameter | Description |
|---|---|
| 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.
String[] 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.
| Parameter | Description |
|---|---|
| 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.