C# String StartsWith(String, StringComparison)
Description
String StartsWith(String, StringComparison)
determines
whether the beginning of this string instance matches the specified string
when compared using the specified comparison option.
Syntax
String.StartsWith(String, StringComparison)
has the following syntax.
[ComVisibleAttribute(false)]/*from w ww .j av a 2s . c om*/
public bool StartsWith(
string value,
StringComparison comparisonType
)
Parameters
String.StartsWith(String, StringComparison)
has the following parameters.
value
- The string to compare.comparisonType
- One of the enumeration values that determines how this string and value are compared.
Returns
String.StartsWith(String, StringComparison)
method returns true if this instance begins with value; otherwise, false.
Example
The following example determines whether a string starts with a particular substring.
using System;//from ww w .j av a 2s. c om
public class Example
{
public static void Main()
{
Console.WriteLine("java2s.com".StartsWith("java", StringComparison.CurrentCulture));
}
}
The code above generates the following result.