System.Globalization.CompareInfo.IsPrefix Method

Determines whether the specified source string starts with the specified prefix.

Syntax

public virtual bool IsPrefix (string source, string prefix)

Parameters

source
The string to search in.
prefix
The string to compare with the beginning of source.

Returns

true if the length of prefix is less than or equal to the length of source and source starts with prefix; otherwise, false.

Remarks

Every string starts and ends with an empty substring (""); therefore, if prefix is an empty string, this method returns true.

Note:

When possible, you should call string comparison methods that have a parameter of type System.Globalization.CompareOptions to specify the kind of comparison expected. As a general rule, use linguistic options (using the current culture) for comparing strings displayed in the user interface and specify CompareOptions.Ordinal or CompareOptions.OrdinalIgnoreCase for security comparisons.

Requirements

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