C# String StartsWith(String, Boolean, CultureInfo)
Description
String StartsWith(String, Boolean, CultureInfo)
determines
whether the beginning of this string instance matches the specified string
when compared using the specified culture.
Syntax
String.StartsWith(String, Boolean, CultureInfo)
has the following syntax.
public bool StartsWith(
string value,//from w ww.jav a 2s . c o m
bool ignoreCase,
CultureInfo culture
)
Parameters
String.StartsWith(String, Boolean, CultureInfo)
has the following parameters.
value
- The string to compare.ignoreCase
- true to ignore case during the comparison; otherwise, false.culture
- Cultural information that determines how this string and value are compared. If culture is null, the current culture is used.
Returns
String.StartsWith(String, Boolean, CultureInfo)
method returns true if the value parameter matches the beginning of this string; otherwise,
false.
Example
The following example determines whether a string occurs at the beginning of another string.
using System;//from ww w. j a v a 2s . c o m
using System.Threading;
using System.Globalization;
class Sample
{
public static void Main()
{
bool result = false;
result = "asdf".StartsWith("ASDF", false, CultureInfo.InvariantCulture);
Console.WriteLine(result);
}
}
The code above generates the following result.