System.String.StartsWith Method

Determines whether the beginning of this string instance matches the specified string when compared using the specified comparison option.

Syntax

[System.Runtime.InteropServices.ComVisible(false)]
public bool StartsWith (string value, StringComparison comparisonType)

Parameters

value
The string to compare.
comparisonType
One of the enumeration values that determines how this string and value are compared.

Returns

true if this instance begins with value; otherwise, false.

Remarks

The string.StartsWith(string, StringComparison) method compares the value parameter to the substring at the beginning of this string and returns a value that indicates whether they are equal. To be equal, value must be a reference to this same string, must be the empty string (""), or must match the beginning of this string. The type of comparison performed by the string.StartsWith(string, StringComparison) method depends on the value of the comparisonType parameter. The comparison can use the conventions of the current culture (StringComparison.CurrentCulture and StringComparison.CurrentCultureIgnoreCase) or the invariant culture (StringComparison.InvariantCulture and StringComparison.InvariantCultureIgnoreCase), or it can consist of a character-by-character comparison of code points (StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase). The comparison can also be case-sensitive (StringComparison.CurrentCulture, StringComparison.InvariantCulture, or StringComparison.Ordinal), or it can ignore case (StringComparison.CurrentCultureIgnoreCase, StringComparison.InvariantCultureIgnoreCase, StringComparison.OrdinalIgnoreCase).

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0