Skip to content

Instantly share code, notes, and snippets.

@mattwarren
Created June 30, 2011 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattwarren/1056242 to your computer and use it in GitHub Desktop.
Save mattwarren/1056242 to your computer and use it in GitHub Desktop.
StartsWidth Locale issues
public static void RunSnippet()
{
var wholeString = "daab";
var prefix = "da";
WL("{0}.StartsWith({1}) = {2}", wholeString, prefix, wholeString.StartsWith(prefix));
WL("{0}.StartsWith({1}, StringComparision.InvariantCulture) = {2}", wholeString, prefix,
wholeString.StartsWith(prefix, StringComparison.InvariantCulture));
WL("-------------------------");
WL("Changing locale to \"da\"");
WL("-------------------------");
var culture = CultureInfo.CreateSpecificCulture("da");
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
WL("{0}.StartsWith({1}) = {2}", wholeString, prefix, wholeString.StartsWith(prefix));
WL("{0}.StartsWith({1}, StringComparision.InvariantCulture) = {2}", wholeString, prefix,
wholeString.StartsWith(prefix, StringComparison.InvariantCulture));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment