System.String.StartsWith Method

Determines whether the beginning of this string instance matches the specified string.

Syntax

public bool StartsWith (string value)

Parameters

value
The string to compare.

Returns

true if value matches the beginning of this string; otherwise, false.

Exceptions

TypeReason
ArgumentNullException value is a null reference.

Remarks

This method compares value to the substring at the beginning of this instance that is the same length as value, and returns an indication whether they are equal. To be equal, value must be an empty string (string.Empty), must be a reference to this same instance, or must match the beginning of this instance.

This method performs a word (case-sensitive and culture-sensitive) comparison using the current culture.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0