Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​String
Assembly: System.Runtime
Inheritance: object → String
Represents text as a sequence of UTF-16 code units.
Fields and Constants
public static readonly
string
Empty
Represents the empty string. This field is read-only.
Properties
public
char
Chars
public
int
Length
Gets the number of characters in the current <see cref="T:System.String" /> object.
Methods
public
object
Clone​() Returns This instance of <see cref="T:System.String" /> .
Returns a reference to this instance of <see cref="T:System.String" /> .
public
int
CompareTo​(object value)
value
An object that evaluates to a <see cref="T:System.String" /> .
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 <paramref name="value" /> parameter.
<list type="table">
<listheader>
<term> Value</term>
<description> Condition</description>
</listheader>
<item>
<term> Less than zero</term>
<description> This instance precedes <paramref name="value" />.</description>
</item>
<item>
<term> Zero</term>
<description> This instance has the same position in the sort order as <paramref name="value" />.</description>
</item>
<item>
<term> Greater than zero</term>
<description> This instance follows <paramref name="value" />.
-or-
<paramref name="value" /> is <see langword="null" />.</description>
</item>
</list>
Compares this instance with a specified <see cref="T:System.Object" /> and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified <see cref="T:System.Object" /> .
public
int
CompareTo​(string strB)
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 <paramref name="strB" /> parameter.
<list type="table">
<listheader>
<term> Value</term>
<description> Condition</description>
</listheader>
<item>
<term> Less than zero</term>
<description> This instance precedes <paramref name="strB" />.</description>
</item>
<item>
<term> Zero</term>
<description> This instance has the same position in the sort order as <paramref name="strB" />.</description>
</item>
<item>
<term> Greater than zero</term>
<description> This instance follows <paramref name="strB" />.
-or-
<paramref name="strB" /> is <see langword="null" />.</description>
</item>
</list>
Compares this instance with a specified <see cref="T:System.String" /> object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified string.
public
bool
Contains​(char value)
value
The character to seek.
Returns <see langword="true" /> if the <paramref name="value" /> parameter occurs within this string; otherwise, <see langword="false" /> .
Returns a value indicating whether a specified character occurs within this string.
public
bool
Contains​(char value,
StringComparison comparisonType)
value
The character to seek.
comparisonType
One of the enumeration values that specifies the rules to use in the comparison.
Returns <see langword="true" /> if the <paramref name="value" /> parameter occurs within this string; otherwise, <see langword="false" /> .
Returns a value indicating whether a specified character occurs within this string, using the specified comparison rules.
public
bool
Contains​(string value)
value
The string to seek.
Returns <see langword="true" /> if the <paramref name="value" /> parameter occurs within this string, or if <paramref name="value" /> is the empty string (""); otherwise, <see langword="false" /> .
Returns a value indicating whether a specified substring occurs within this string.
public
bool
Contains​(string value,
StringComparison comparisonType)
value
The string to seek.
comparisonType
One of the enumeration values that specifies the rules to use in the comparison.
Returns <see langword="true" /> if the <paramref name="value" /> parameter occurs within this string, or if <paramref name="value" /> is the empty string (""); otherwise, <see langword="false" /> .
Returns a value indicating whether a specified string occurs within this string, using the specified comparison rules.
public
void
CopyTo​(int sourceIndex,
char[] destination,
int destinationIndex,
int count)
sourceIndex
The index of the first character in this instance to copy.
destination
An array of Unicode characters to which characters in this instance are copied.
destinationIndex
The index in <paramref name="destination" /> at which the copy operation begins.
count
The number of characters in this instance to copy to <paramref name="destination" /> .
Copies a specified number of characters from a specified position in this instance to a specified position in an array of Unicode characters.
public
bool
EndsWith​(char value)
value
The character to compare to the character at the end of this instance.
Returns <see langword="true" /> if <paramref name="value" /> matches the end of this instance; otherwise, <see langword="false" /> .
Determines whether the end of this string instance matches the specified character.
public
bool
EndsWith​(string value)
value
The string to compare to the substring at the end of this instance.
Returns <see langword="true" /> if <paramref name="value" /> matches the end of this instance; otherwise, <see langword="false" /> .
Determines whether the end of this string instance matches the specified string.
public
bool
EndsWith​(string value,
bool ignoreCase,
CultureInfo culture)
value
The string to compare to the substring at the end of this instance.
ignoreCase
<see langword="true" /> to ignore case during the comparison; otherwise, <see langword="false" /> .
culture
Cultural information that determines how this instance and <paramref name="value" /> are compared. If <paramref name="culture" /> is <see langword="null" /> , the current culture is used.
Returns <see langword="true" /> if the <paramref name="value" /> parameter matches the end of this string; otherwise, <see langword="false" /> .
Determines whether the end of this string instance matches the specified string when compared using the specified culture.
public
bool
EndsWith​(string value,
StringComparison comparisonType)
value
The string to compare to the substring at the end of this instance.
comparisonType
One of the enumeration values that determines how this string and <paramref name="value" /> are compared.
Returns <see langword="true" /> if the <paramref name="value" /> parameter matches the end of this string; otherwise, <see langword="false" /> .
Determines whether the end of this string instance matches the specified string when compared using the specified comparison option.
Returns an enumeration of <see cref="T:System.Text.Rune" /> from this string.
public
bool
Equals​(object obj)
obj
The string to compare to this instance.
Returns <see langword="true" /> if <paramref name="obj" /> is a <see cref="T:System.String" /> and its value is the same as this instance; otherwise, <see langword="false" /> . If <paramref name="obj" /> is <see langword="null" /> , the method returns <see langword="false" /> .
Determines whether this instance and a specified object, which must also be a <see cref="T:System.String" /> object, have the same value.
public
bool
Equals​(string value)
value
The string to compare to this instance.
Returns <see langword="true" /> if the value of the <paramref name="value" /> parameter is the same as the value of this instance; otherwise, <see langword="false" /> . If <paramref name="value" /> is <see langword="null" /> , the method returns <see langword="false" /> .
Determines whether this instance and another specified <see cref="T:System.String" /> object have the same value.
public
bool
Equals​(string value,
StringComparison comparisonType)
value
The string to compare to this instance.
comparisonType
One of the enumeration values that specifies how the strings will be compared.
Returns <see langword="true" /> if the value of the <paramref name="value" /> parameter is the same as this string; otherwise, <see langword="false" /> .
Determines whether this string and a specified <see cref="T:System.String" /> object have the same value. A parameter specifies the culture, case, and sort rules used in the comparison.
Retrieves an object that can iterate through the individual characters in this string.
public
int
GetHashCode​() Returns A 32-bit signed integer hash code.
Returns the hash code for this string.
public
int
GetHashCode​(StringComparison comparisonType)
comparisonType
One of the enumeration values that specifies the rules to use in the comparison.
Returns A 32-bit signed integer hash code.
Returns the hash code for this string using the specified rules.
public
Char&
GetPinnableReference​() Returns A reference to the first character in the string, or a reference to the string's null terminator if the string is empty.
Returns a reference to the element of the string at index zero.
This method is intended to support .NET compilers and is not intended to be called by user code.
public
TypeCode
GetTypeCode​() Returns The enumerated constant, <see cref="F:System.TypeCode.String" /> .
Returns the <see cref="T:System.TypeCode" /> for the <see cref="T:System.String" /> class.
public
int
IndexOf​(char value)
value
A Unicode character to seek.
Returns The zero-based index position of <paramref name="value" /> if that character is found, or -1 if it is not.
Reports the zero-based index of the first occurrence of the specified Unicode character in this string.
public
int
IndexOf​(char value,
int startIndex)
value
A Unicode character to seek.
startIndex
The search starting position.
Returns The zero-based index position of <paramref name="value" /> from the start of the string if that character is found, or -1 if it is not.
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
int
IndexOf​(char value,
int startIndex,
int count)
value
A Unicode character to seek.
startIndex
The search starting position.
count
The number of character positions to examine.
Returns The zero-based index position of <paramref name="value" /> from the start of the string if that character is found, or -1 if it is not.
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
int
IndexOf​(char value,
StringComparison comparisonType)
value
The character to seek.
comparisonType
An enumeration value that specifies the rules for the search.
Returns The zero-based index of <paramref name="value" /> if that character is found, or -1 if it is not.
Reports the zero-based index of the first occurrence of the specified Unicode character in this string. A parameter specifies the type of search to use for the specified character.
public
int
IndexOf​(string value)
value
The string to seek.
Returns The zero-based index position of <paramref name="value" /> if that string is found, or -1 if it is not. If <paramref name="value" /> is <see cref="F:System.String.Empty" /> , the return value is 0.
Reports the zero-based index of the first occurrence of the specified string in this instance.
public
int
IndexOf​(string value,
int startIndex)
value
The string to seek.
startIndex
The search starting position.
Returns The zero-based index position of <paramref name="value" /> from the start of the current instance if that string is found, or -1 if it is not. If <paramref name="value" /> is <see cref="F:System.String.Empty" /> , the return value is <paramref name="startIndex" /> .
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
int
IndexOf​(string value,
int startIndex,
int count)
value
The string to seek.
startIndex
The search starting position.
count
The number of character positions to examine.
Returns The zero-based index position of <paramref name="value" /> from the start of the current instance if that string is found, or -1 if it is not. If <paramref name="value" /> is <see cref="F:System.String.Empty" /> , the return value is <paramref name="startIndex" /> .
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
int
IndexOf​(string value,
int startIndex,
int count,
StringComparison comparisonType)
value
The string to seek.
startIndex
The search starting position.
count
The number of character positions to examine.
comparisonType
One of the enumeration values that specifies the rules for the search.
Returns The zero-based index position of the <paramref name="value" /> parameter from the start of the current instance if that string is found, or -1 if it is not. If <paramref name="value" /> is <see cref="F:System.String.Empty" /> , the return value is <paramref name="startIndex" /> .
Reports the zero-based index of the first occurrence of the specified string in the current <see cref="T:System.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
int
IndexOf​(string value,
int startIndex,
StringComparison comparisonType)
value
The string to seek.
startIndex
The search starting position.
comparisonType
One of the enumeration values that specifies the rules for the search.
Returns The zero-based index position of the <paramref name="value" /> parameter from the start of the current instance if that string is found, or -1 if it is not. If <paramref name="value" /> is <see cref="F:System.String.Empty" /> , the return value is <paramref name="startIndex" /> .
Reports the zero-based index of the first occurrence of the specified string in the current <see cref="T:System.String" /> object. Parameters specify the starting search position in the current string and the type of search to use for the specified string.
public
int
IndexOf​(string value,
StringComparison comparisonType)
value
The string to seek.
comparisonType
One of the enumeration values that specifies the rules for the search.
Returns The index position of the <paramref name="value" /> parameter if that string is found, or -1 if it is not. If <paramref name="value" /> is <see cref="F:System.String.Empty" /> , the return value is 0.
Reports the zero-based index of the first occurrence of the specified string in the current <see cref="T:System.String" /> object. A parameter specifies the type of search to use for the specified string.
public
int
IndexOfAny​(char[] anyOf)
anyOf
A Unicode character array containing one or more characters to seek.
Returns The zero-based index position of the first occurrence in this instance where any character in <paramref name="anyOf" /> was found; -1 if no character in <paramref name="anyOf" /> was found.
Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters.
public
int
IndexOfAny​(char[] anyOf,
int startIndex)
anyOf
A Unicode character array containing one or more characters to seek.
startIndex
The search starting position.
Returns The zero-based index position of the first occurrence in this instance where any character in <paramref name="anyOf" /> was found; -1 if no character in <paramref name="anyOf" /> was found.
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
int
IndexOfAny​(char[] anyOf,
int startIndex,
int count)
anyOf
A Unicode character array containing one or more characters to seek.
startIndex
The search starting position.
count
The number of character positions to examine.
Returns The zero-based index position of the first occurrence in this instance where any character in <paramref name="anyOf" /> was found; -1 if no character in <paramref name="anyOf" /> was found.
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
string
Insert​(int startIndex,
string value)
startIndex
The zero-based index position of the insertion.
value
The string to insert.
Returns A new string that is equivalent to this instance, but with <paramref name="value" /> inserted at position <paramref name="startIndex" /> .
Returns a new string in which a specified string is inserted at a specified index position in this instance.
public
bool
IsNormalized​() Returns <see langword="true" /> if this string is in normalization form C; otherwise, <see langword="false" /> .
Indicates whether this string is in Unicode normalization form C.
public
bool
IsNormalized​(NormalizationForm normalizationForm)
normalizationForm
A Unicode normalization form.
Returns <see langword="true" /> if this string is in the normalization form specified by the <paramref name="normalizationForm" /> parameter; otherwise, <see langword="false" /> .
Indicates whether this string is in the specified Unicode normalization form.
public
int
LastIndexOf​(char value)
value
The Unicode character to seek.
Returns The zero-based index position of <paramref name="value" /> if that character is found, or -1 if it is not.
Reports the zero-based index position of the last occurrence of a specified Unicode character within this instance.
public
int
LastIndexOf​(char value,
int startIndex)
value
The Unicode character to seek.
startIndex
The starting position of the search. The search proceeds from <paramref name="startIndex" /> toward the beginning of this instance.
Returns The zero-based index position of <paramref name="value" /> if that character is found, or -1 if it is not found or if the current instance equals <see cref="F:System.String.Empty" /> .
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
int
LastIndexOf​(char value,
int startIndex,
int count)
value
The Unicode character to seek.
startIndex
The starting position of the search. The search proceeds from <paramref name="startIndex" /> toward the beginning of this instance.
count
The number of character positions to examine.
Returns The zero-based index position of <paramref name="value" /> if that character is found, or -1 if it is not found or if the current instance equals <see cref="F:System.String.Empty" /> .
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
int
LastIndexOf​(string value)
value
The string to seek.
Returns The zero-based starting index position of <paramref name="value" /> if that string is found, or -1 if it is not.
Reports the zero-based index position of the last occurrence of a specified string within this instance.
public
int
LastIndexOf​(string value,
int startIndex)
value
The string to seek.
startIndex
The search starting position. The search proceeds from <paramref name="startIndex" /> toward the beginning of this instance.
Returns The zero-based starting index position of <paramref name="value" /> if that string is found, or -1 if it is not found or if the current instance equals <see cref="F:System.String.Empty" /> .
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
int
LastIndexOf​(string value,
int startIndex,
int count)
value
The string to seek.
startIndex
The search starting position. The search proceeds from <paramref name="startIndex" /> toward the beginning of this instance.
count
The number of character positions to examine.
Returns The zero-based starting index position of <paramref name="value" /> if that string is found, or -1 if it is not found or if the current instance equals <see cref="F:System.String.Empty" /> .
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
int
LastIndexOf​(string value,
int startIndex,
int count,
StringComparison comparisonType)
value
The string to seek.
startIndex
The search starting position. The search proceeds from <paramref name="startIndex" /> toward the beginning of this instance.
count
The number of character positions to examine.
comparisonType
One of the enumeration values that specifies the rules for the search.
Returns The zero-based starting index position of the <paramref name="value" /> parameter if that string is found, or -1 if it is not found or if the current instance equals <see cref="F:System.String.Empty" /> .
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 the specified number of character positions. A parameter specifies the type of comparison to perform when searching for the specified string.
public
int
LastIndexOf​(string value,
int startIndex,
StringComparison comparisonType)
value
The string to seek.
startIndex
The search starting position. The search proceeds from <paramref name="startIndex" /> toward the beginning of this instance.
comparisonType
One of the enumeration values that specifies the rules for the search.
Returns The zero-based starting index position of the <paramref name="value" /> parameter if that string is found, or -1 if it is not found or if the current instance equals <see cref="F:System.String.Empty" /> .
Reports the zero-based index of the last occurrence of a specified string within the current <see cref="T:System.String" /> object. The search starts at a specified character position and proceeds backward toward the beginning of the string. A parameter specifies the type of comparison to perform when searching for the specified string.
public
int
LastIndexOf​(string value,
StringComparison comparisonType)
value
The string to seek.
comparisonType
One of the enumeration values that specifies the rules for the search.
Returns The zero-based starting index position of the <paramref name="value" /> parameter if that string is found, or -1 if it is not.
Reports the zero-based index of the last occurrence of a specified string within the current <see cref="T:System.String" /> object. A parameter specifies the type of search to use for the specified string.
public
int
LastIndexOfAny​(char[] anyOf)
anyOf
A Unicode character array containing one or more characters to seek.
Returns The index position of the last occurrence in this instance where any character in <paramref name="anyOf" /> was found; -1 if no character in <paramref name="anyOf" /> was found.
Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array.
public
int
LastIndexOfAny​(char[] anyOf,
int startIndex)
anyOf
A Unicode character array containing one or more characters to seek.
startIndex
The search starting position. The search proceeds from <paramref name="startIndex" /> toward the beginning of this instance.
Returns The index position of the last occurrence in this instance where any character in <paramref name="anyOf" /> was found; -1 if no character in <paramref name="anyOf" /> was found or if the current instance equals <see cref="F:System.String.Empty" /> .
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
int
LastIndexOfAny​(char[] anyOf,
int startIndex,
int count)
anyOf
A Unicode character array containing one or more characters to seek.
startIndex
The search starting position. The search proceeds from <paramref name="startIndex" /> toward the beginning of this instance.
count
The number of character positions to examine.
Returns The index position of the last occurrence in this instance where any character in <paramref name="anyOf" /> was found; -1 if no character in <paramref name="anyOf" /> was found or if the current instance equals <see cref="F:System.String.Empty" /> .
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
string
Normalize​() Returns A new, normalized string whose textual value is the same as this string, but whose binary representation is in normalization form C.
Returns a new string whose textual value is the same as this string, but whose binary representation is in Unicode normalization form C.
public
string
Normalize​(NormalizationForm normalizationForm)
normalizationForm
A Unicode normalization form.
Returns A new string whose textual value is the same as this string, but whose binary representation is in the normalization form specified by the <paramref name="normalizationForm" /> parameter.
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
string
PadLeft​(int totalWidth)
totalWidth
The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters.
Returns A new string that is equivalent to this instance, but right-aligned and padded on the left with as many spaces as needed to create a length of <paramref name="totalWidth" /> . However, if <paramref name="totalWidth" /> is less than the length of this instance, the method returns a reference to the existing instance. If <paramref name="totalWidth" /> is equal to the length of this instance, the method returns a new string that is identical to this instance.
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
string
PadLeft​(int totalWidth,
char paddingChar)
totalWidth
The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters.
paddingChar
A Unicode padding character.
Returns A new string that is equivalent to this instance, but right-aligned and padded on the left with as many <paramref name="paddingChar" /> characters as needed to create a length of <paramref name="totalWidth" /> . However, if <paramref name="totalWidth" /> is less than the length of this instance, the method returns a reference to the existing instance. If <paramref name="totalWidth" /> is equal to the length of this instance, the method returns a new string that is identical to this instance.
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
string
PadRight​(int totalWidth)
totalWidth
The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters.
Returns A new string that is equivalent to this instance, but left-aligned and padded on the right with as many spaces as needed to create a length of <paramref name="totalWidth" /> . However, if <paramref name="totalWidth" /> is less than the length of this instance, the method returns a reference to the existing instance. If <paramref name="totalWidth" /> is equal to the length of this instance, the method returns a new string that is identical to this instance.
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
string
PadRight​(int totalWidth,
char paddingChar)
totalWidth
The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters.
paddingChar
A Unicode padding character.
Returns A new string that is equivalent to this instance, but left-aligned and padded on the right with as many <paramref name="paddingChar" /> characters as needed to create a length of <paramref name="totalWidth" /> . However, if <paramref name="totalWidth" /> is less than the length of this instance, the method returns a reference to the existing instance. If <paramref name="totalWidth" /> is equal to the length of this instance, the method returns a new string that is identical to this instance.
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
string
Remove​(int startIndex)
startIndex
The zero-based position to begin deleting characters.
Returns A new string that is equivalent to this string except for the removed characters.
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
string
Remove​(int startIndex,
int count)
startIndex
The zero-based position to begin deleting characters.
count
The number of characters to delete.
Returns A new string that is equivalent to this instance except for the removed characters.
Returns a new string in which a specified number of characters in the current instance beginning at a specified position have been deleted.
public
string
Replace​(char oldChar,
char newChar)
oldChar
The Unicode character to be replaced.
newChar
The Unicode character to replace all occurrences of <paramref name="oldChar" /> .
Returns A string that is equivalent to this instance except that all instances of <paramref name="oldChar" /> are replaced with <paramref name="newChar" /> . If <paramref name="oldChar" /> is not found in the current instance, the method returns the current instance unchanged.
Returns a new string in which all occurrences of a specified Unicode character in this instance are replaced with another specified Unicode character.
public
string
Replace​(string oldValue,
string newValue)
oldValue
The string to be replaced.
newValue
The string to replace all occurrences of <paramref name="oldValue" /> .
Returns A string that is equivalent to the current string except that all instances of <paramref name="oldValue" /> are replaced with <paramref name="newValue" /> . If <paramref name="oldValue" /> is not found in the current instance, the method returns the current instance unchanged.
Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string.
public
string
Replace​(string oldValue,
string newValue,
bool ignoreCase,
CultureInfo culture)
oldValue
The string to be replaced.
newValue
The string to replace all occurrences of <paramref name="oldValue" /> .
ignoreCase
<see langword="true" /> to ignore casing when comparing; <see langword="false" /> otherwise.
culture
The culture to use when comparing. If <paramref name="culture" /> is <see langword="null" /> , the current culture is used.
Returns A string that is equivalent to the current string except that all instances of <paramref name="oldValue" /> are replaced with <paramref name="newValue" /> . If <paramref name="oldValue" /> is not found in the current instance, the method returns the current instance unchanged.
Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string, using the provided culture and case sensitivity.
public
string
Replace​(string oldValue,
string newValue,
StringComparison comparisonType)
oldValue
The string to be replaced.
newValue
The string to replace all occurrences of <paramref name="oldValue" /> .
comparisonType
One of the enumeration values that determines how <paramref name="oldValue" /> is searched within this instance.
Returns A string that is equivalent to the current string except that all instances of <paramref name="oldValue" /> are replaced with <paramref name="newValue" /> . If <paramref name="oldValue" /> is not found in the current instance, the method returns the current instance unchanged.
Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string, using the provided comparison type.
public
string
ReplaceLineEndings​() Returns A string whose contents match the current string, but with all newline sequences replaced with <see cref="P:System.Environment.NewLine" /> .
Replaces all newline sequences in the current string with <see cref="P:System.Environment.NewLine" /> .
public
string
ReplaceLineEndings​(string replacementText)
replacementText
The text to use as replacement.
Returns A string whose contents match the current string, but with all newline sequences replaced with <paramref name="replacementText" /> .
Replaces all newline sequences in the current string with <paramref name="replacementText" /> .
public
string[]
Split​(char separator,
int count,
StringSplitOptions options = 0)
separator
A character that delimits the substrings in this instance.
count
The maximum number of elements expected in the array.
options
A bitwise combination of the enumeration values that specifies whether to trim substrings and include empty substrings.
Returns An array that contains at most <paramref name="count" /> substrings from this instance that are delimited by <paramref name="separator" /> .
Splits a string into a maximum number of substrings based on the provided character separator, optionally omitting empty substrings from the result.
public
string[]
Split​(char separator,
StringSplitOptions options = 0)
separator
A character that delimits the substrings in this string.
options
A bitwise combination of the enumeration values that specifies whether to trim substrings and include empty substrings.
Returns An array whose elements contain the substrings from this instance that are delimited by <paramref name="separator" /> .
Splits a string into substrings based on a specified delimiting character and, optionally, options.
public
string[]
Split​(char[] separator)
separator
An array of delimiting characters, an empty array that contains no delimiters, or <see langword="null" /> .
Returns An array whose elements contain the substrings from this instance that are delimited by one or more characters in <paramref name="separator" /> . For more information, see the Remarks section.
Splits a string into substrings based on specified delimiting characters.
public
string[]
Split​(char[] separator,
int count)
separator
An array of characters that delimit the substrings in this string, an empty array that contains no delimiters, or <see langword="null" /> .
count
The maximum number of substrings to return.
Returns An array whose elements contain the substrings in this instance that are delimited by one or more characters in <paramref name="separator" /> . For more information, see the Remarks section.
Splits a string into a maximum number of substrings based on specified delimiting characters.
public
string[]
Split​(char[] separator,
int count,
StringSplitOptions options)
separator
An array of characters that delimit the substrings in this string, an empty array that contains no delimiters, or <see langword="null" /> .
count
The maximum number of substrings to return.
options
A bitwise combination of the enumeration values that specifies whether to trim substrings and include empty substrings.
Returns An array that contains the substrings in this string that are delimited by one or more characters in <paramref name="separator" /> . For more information, see the Remarks section.
Splits a string into a maximum number of substrings based on specified delimiting characters and, optionally, options.
public
string[]
Split​(char[] separator,
StringSplitOptions options)
separator
An array of characters that delimit the substrings in this string, an empty array that contains no delimiters, or <see langword="null" /> .
options
A bitwise combination of the enumeration values that specifies whether to trim substrings and include empty substrings.
Returns An array whose elements contain the substrings in this string that are delimited by one or more characters in <paramref name="separator" /> . For more information, see the Remarks section.
Splits a string into substrings based on specified delimiting characters and options.
public
string[]
Split​(string separator,
int count,
StringSplitOptions options = 0)
separator
A string that delimits the substrings in this instance.
count
The maximum number of elements expected in the array.
options
A bitwise combination of the enumeration values that specifies whether to trim substrings and include empty substrings.
Returns An array that contains at most <paramref name="count" /> substrings from this instance that are delimited by <paramref name="separator" /> .
Splits a string into a maximum number of substrings based on a specified delimiting string and, optionally, options.
public
string[]
Split​(string separator,
StringSplitOptions options = 0)
separator
A string that delimits the substrings in this string.
options
A bitwise combination of the enumeration values that specifies whether to trim substrings and include empty substrings.
Returns An array whose elements contain the substrings from this instance that are delimited by <paramref name="separator" /> .
Splits a string into substrings that are based on the provided string separator.
public
string[]
Split​(string[] separator,
int count,
StringSplitOptions options)
separator
The strings that delimit the substrings in this string, an empty array that contains no delimiters, or <see langword="null" /> .
count
The maximum number of substrings to return.
options
A bitwise combination of the enumeration values that specifies whether to trim substrings and include empty substrings.
Returns An array whose elements contain the substrings in this string that are delimited by one or more strings in <paramref name="separator" /> . For more information, see the Remarks section.
Splits a string into a maximum number of substrings based on specified delimiting strings and, optionally, options.
public
string[]
Split​(string[] separator,
StringSplitOptions options)
separator
An array of strings that delimit the substrings in this string, an empty array that contains no delimiters, or <see langword="null" /> .
options
A bitwise combination of the enumeration values that specifies whether to trim substrings and include empty substrings.
Returns An array whose elements contain the substrings in this string that are delimited by one or more strings in <paramref name="separator" /> . For more information, see the Remarks section.
Splits a string into substrings based on a specified delimiting string and, optionally, options.
public
bool
StartsWith​(char value)
value
The character to compare.
Returns <see langword="true" /> if <paramref name="value" /> matches the beginning of this string; otherwise, <see langword="false" /> .
Determines whether this string instance starts with the specified character.
public
bool
StartsWith​(string value)
value
The string to compare.
Returns <see langword="true" /> if <paramref name="value" /> matches the beginning of this string; otherwise, <see langword="false" /> .
Determines whether the beginning of this string instance matches the specified string.
public
bool
StartsWith​(string value,
bool ignoreCase,
CultureInfo culture)
value
The string to compare.
ignoreCase
<see langword="true" /> to ignore case during the comparison; otherwise, <see langword="false" /> .
culture
Cultural information that determines how this string and <paramref name="value" /> are compared. If <paramref name="culture" /> is <see langword="null" /> , the current culture is used.
Returns <see langword="true" /> if the <paramref name="value" /> parameter matches the beginning of this string; otherwise, <see langword="false" /> .
Determines whether the beginning of this string instance matches the specified string when compared using the specified culture.
public
bool
StartsWith​(string value,
StringComparison comparisonType)
value
The string to compare.
comparisonType
One of the enumeration values that determines how this string and <paramref name="value" /> are compared.
Returns <see langword="true" /> if this instance begins with <paramref name="value" /> ; otherwise, <see langword="false" /> .
Determines whether the beginning of this string instance matches the specified string when compared using the specified comparison option.
public
string
Substring​(int startIndex)
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 <paramref name="startIndex" /> in this instance, or <see cref="F:System.String.Empty" /> if <paramref name="startIndex" /> is equal to the length of this instance.
Retrieves a substring from this instance. The substring starts at a specified character position and continues to the end of the string.
public
string
Substring​(int startIndex,
int length)
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 <paramref name="length" /> that begins at <paramref name="startIndex" /> in this instance, or <see cref="F:System.String.Empty" /> if <paramref name="startIndex" /> is equal to the length of this instance and <paramref name="length" /> is zero.
Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.
public
char[]
ToCharArray​() 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.
Copies the characters in this instance to a Unicode character array.
public
char[]
ToCharArray​(int startIndex,
int length)
startIndex
The starting position of a substring in this instance.
length
The length of the substring in this instance.
Returns A Unicode character array whose elements are the <paramref name="length" /> number of characters in this instance starting from character position <paramref name="startIndex" /> .
Copies the characters in a specified substring in this instance to a Unicode character array.
public
string
ToLower​() Returns A string in lowercase.
Returns a copy of this string converted to lowercase.
public
string
ToLower​(CultureInfo culture)
culture
An object that supplies culture-specific casing rules. If <paramref name="culture" /> is <see langword="null" /> , the current culture is used.
Returns The lowercase equivalent of the current string.
Returns a copy of this string converted to lowercase, using the casing rules of the specified culture.
public
string
ToLowerInvariant​() Returns The lowercase equivalent of the current string.
Returns a copy of this <see cref="T:System.String" /> object converted to lowercase using the casing rules of the invariant culture.
public
string
ToString​() Returns The current string.
Returns this instance of <see cref="T:System.String" /> ; no actual conversion is performed.
public
string
ToString​(IFormatProvider provider)
provider
(Reserved) An object that supplies culture-specific formatting information.
Returns The current string.
Returns this instance of <see cref="T:System.String" /> ; no actual conversion is performed.
public
string
ToUpper​() Returns The uppercase equivalent of the current string.
Returns a copy of this string converted to uppercase.
public
string
ToUpper​(CultureInfo culture)
culture
An object that supplies culture-specific casing rules. If <paramref name="culture" /> is <see langword="null" /> , the current culture is used.
Returns The uppercase equivalent of the current string.
Returns a copy of this string converted to uppercase, using the casing rules of the specified culture.
public
string
ToUpperInvariant​() Returns The uppercase equivalent of the current string.
Returns a copy of this <see cref="T:System.String" /> object converted to uppercase using the casing rules of the invariant culture.
public
string
Trim​() 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.
Removes all leading and trailing white-space characters from the current string.
public
string
Trim​(char trimChar)
trimChar
A Unicode character to remove.
Returns The string that remains after all instances of the <paramref name="trimChar" /> character 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.
Removes all leading and trailing instances of a character from the current string.
public
string
Trim​(char[] trimChars)
trimChars
An array of Unicode characters to remove, or <see langword="null" /> .
Returns The string that remains after all occurrences of the characters in the <paramref name="trimChars" /> parameter are removed from the start and end of the current string. If <paramref name="trimChars" /> is <see langword="null" /> or an empty array, white-space characters are removed instead. If no characters can be trimmed from the current instance, the method returns the current instance unchanged.
Removes all leading and trailing occurrences of a set of characters specified in an array from the current string.
public
string
TrimEnd​() Returns The string that remains after all white-space characters are removed from the end of the current string. If no characters can be trimmed from the current instance, the method returns the current instance unchanged.
Removes all the trailing white-space characters from the current string.
public
string
TrimEnd​(char trimChar)
trimChar
A Unicode character to remove.
Returns The string that remains after all occurrences of the <paramref name="trimChar" /> character are removed from the end of the current string. If no characters can be trimmed from the current instance, the method returns the current instance unchanged.
Removes all the trailing occurrences of a character from the current string.
public
string
TrimEnd​(char[] trimChars)
trimChars
An array of Unicode characters to remove, or <see langword="null" /> .
Returns The string that remains after all occurrences of the characters in the <paramref name="trimChars" /> parameter are removed from the end of the current string. If <paramref name="trimChars" /> is <see langword="null" /> or an empty array, Unicode white-space characters are removed instead. If no characters can be trimmed from the current instance, the method returns the current instance unchanged.
Removes all the trailing occurrences of a set of characters specified in an array from the current string.
public
string
TrimStart​() Returns The string that remains after all white-space characters are removed from the start of the current string. If no characters can be trimmed from the current instance, the method returns the current instance unchanged.
Removes all the leading white-space characters from the current string.
public
string
TrimStart​(char trimChar)
trimChar
The Unicode character to remove.
Returns The string that remains after all occurrences of the <paramref name="trimChar" /> character are removed from the start of the current string. If no characters can be trimmed from the current instance, the method returns the current instance unchanged.
Removes all the leading occurrences of a specified character from the current string.
public
string
TrimStart​(char[] trimChars)
trimChars
An array of Unicode characters to remove, or <see langword="null" /> .
Returns The string that remains after all occurrences of characters in the <paramref name="trimChars" /> parameter are removed from the start of the current string. If <paramref name="trimChars" /> is <see langword="null" /> or an empty array, white-space characters are removed instead. If no characters can be trimmed from the current instance, the method returns the current instance unchanged.
Removes all the leading occurrences of a set of characters specified in an array from the current string.
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .