本文整理汇总了C#中System.Globalization.CultureInfo.ToUpper方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.ToUpper方法的具体用法?C# CultureInfo.ToUpper怎么用?C# CultureInfo.ToUpper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.CultureInfo
的用法示例。
在下文中一共展示了CultureInfo.ToUpper方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFrFRUpperCaseCharacter
public void TestFrFRUpperCaseCharacter()
{
char ch = 'G';
char expectedChar = ch;
TextInfo textInfo = new CultureInfo("fr-FR").TextInfo;
char actualChar = textInfo.ToUpper(ch);
Assert.Equal(expectedChar, actualChar);
}
示例2: TestTrTRUppercaseCharacter
public void TestTrTRUppercaseCharacter()
{
char ch = '\u0130';
char expectedChar = ch;
TextInfo textInfo = new CultureInfo("tr-TR").TextInfo;
char actualChar = textInfo.ToUpper(ch);
Assert.Equal(expectedChar, actualChar);
}
示例3: TestFrFRStringWithSymbols
public void TestFrFRStringWithSymbols()
{
string strA = "Hello\n\0World\u0009!";
string ActualResult;
TextInfo textInfo = new CultureInfo("fr-FR").TextInfo;
ActualResult = textInfo.ToUpper(strA);
Assert.Equal("HELLO\n\0WORLD\t!", ActualResult);
}
示例4: TestEnUSLowercaseCharacter
public void TestEnUSLowercaseCharacter()
{
char ch = 'a';
char expectedChar = 'A';
TextInfo textInfo = new CultureInfo("en-US").TextInfo;
char actualChar = textInfo.ToUpper(ch);
Assert.Equal(expectedChar, actualChar);
}
示例5: TestEmptyString
public void TestEmptyString()
{
string strA = string.Empty;
string ActualResult;
TextInfo textInfo = new CultureInfo("en-US").TextInfo;
ActualResult = textInfo.ToUpper(strA);
Assert.Equal(string.Empty, ActualResult);
}
示例6: TestTrTRNormalString
public void TestTrTRNormalString()
{
string strA = "H\u0131!";
string ActualResult;
TextInfo textInfo = new CultureInfo("tr-TR").TextInfo;
ActualResult = textInfo.ToUpper(strA);
Assert.Equal("HI!", ActualResult);
}
示例7: TestFrFRNormalString
public void TestFrFRNormalString()
{
string strA = "HelloWorld!";
string ActualResult;
TextInfo textInfo = new CultureInfo("fr-FR").TextInfo;
ActualResult = textInfo.ToUpper(strA);
Assert.Equal("HELLOWORLD!", ActualResult);
}
示例8: TestNonAlphabeticCharacter
public void TestNonAlphabeticCharacter()
{
for (int i = 0; i <= 9; i++)
{
char ch = Convert.ToChar(i);
char expectedChar = ch;
TextInfo textInfo = new CultureInfo("en-US").TextInfo;
char actualChar = textInfo.ToUpper(ch);
Assert.Equal(expectedChar, actualChar);
}
}
示例9: string_advanced_examples
public string_advanced_examples()
{
//escape sequences
string tab = "This is a\t tab.";
string charLiterals = "This is a\' break.";
string newLine = "This is a\n new line.";
string backslash = "This is a \\ backslash because otherwise it wouldn't work properly and it would throw an error.";
string backspace = "this is a backspace \b";
string carriageReturn = "This is a \r carriage return";
/*-----------------------------------------------------
* All escape sequences
* ---------------------------------------------------*/
//\' - single quote, needed for character literals
//\" - double quote, needed for string literals
//\\ - backslash
//\0 - Unicode character 0 (ASCII)
//\a - Alert (character 7)
//\b - Backspace (character 8)
//\f - Form feed (character 12)
//\n - New line (character 10)
//\r - Carriage return (character 13)
//\t - Horizontal tab (character 9)
//\v - Vertical quote (character 11)
//\uxxxx - Unicode escape sequence for character with hex value xxxx
//\xn[n][n][n] - Unicode escape sequence for character with hex value nnnn (variable length version of \uxxxx)
//\Uxxxxxxxx - Unicode escape sequence for character with hex value xxxxxxxx (for generating surrogates)
//verbatims
//In a verbatim string literal, the characters between the delimiters are interpreted verbatim, the only exception being a quote-escape-sequence. In particular, simple escape sequences and hexadecimal and Unicode escape sequences are not processed in verbatim string literals. A verbatim string literal may span multiple lines.
string verbatim = @"And she said, 'Johnny knows the world is cruel but he loves 'it' anyways'.";
Console.WriteLine(verbatim);
//verbatims appear "as-is", meaning it is cleaner and easier to program. You don't need to use escape sequences all over the place.
//case manipulation
Console.WriteLine("\nBegin String case manipulation\n");
string monkey = "monKEYs aRE WILD animals.";
Console.WriteLine("\"{0}\" string lower case: {1}", monkey, monkey.ToLower());// this should take the string and put everything in lower case.
Console.WriteLine("\"{0}\" string upper case: {1}", monkey, monkey.ToUpper());// this should take the string and put everything in upper case.
TextInfo ti = new CultureInfo("en-US", false).TextInfo;
Console.WriteLine("\"{0}\" textinfo upper case: {1}", monkey, ti.ToUpper(monkey));// this should take the string and put everything in upper case.
Console.WriteLine("\"{0}\" textinfo lower case: {1}", monkey, ti.ToLower(monkey));// this should take the string and put everything in lower case.
Console.WriteLine("\"{0}\" textinfo titled case: {1}", monkey, ti.ToTitleCase(monkey));// this should take the string and put everything in titled case.
string bubby = " asdf a sdfsd sd f d f f ";
bubby = bubby.Trim();// removes all white spaces and non-alphabetic characters.
Console.WriteLine("The new and improved bubby is: " + bubby);
//i have no idea what these do.
bubby = bubby.PadLeft(17, 'a');
Console.WriteLine(bubby);
bubby = bubby.PadRight(5, 'u');
Console.WriteLine(bubby);
string attack = "Yummy people are awkward to socalize with.";
Console.WriteLine("Length of attack var is " + attack.Length);//this returns the number of characters of the string. Cannot be invoked like Java.
bool check = true;
while (check == true)
{
if (attack.Contains(':') || attack.Contains('@') || attack.Contains('.') || attack.Contains('='))
{
Console.WriteLine("A SQL injection attempt has been detected. Cleaning input now.");
attack = attack.Replace('.', ' ');
attack = attack.Replace('@', ' ');
attack = attack.Replace(':', ' ');
attack = attack.Replace('=', ' ');
check = true;//this type of logic could be used to check for invalid input that might be used in a SQL injection attack.
}
else
{
Console.WriteLine("SQL injection check completed. As you were.");
check = false;
}
}
//concationating strings
string hank = "Hank Hill";
string peggy = "Peggy Hill";
string married = "are married.";
Console.WriteLine(hank + " and " + peggy + " " + married);
//similar way to do this:
Console.WriteLine("{0} and {1} {2}", hank, peggy, married);// don't have to type as many pluses and "" things.
//concatination is slow. Use the String Builder class for larger strings.
StringBuilder sbuild = new StringBuilder();
sbuild.Append(hank);
sbuild.Append(" and ");
sbuild.Append(peggy);
sbuild.Append(" ");
sbuild.Append(married);
Console.WriteLine(sbuild);
//although there is no output difference this method is more efficient.
}
示例10: MatchEvalChangeCase
// regex match evaluator for changing case
private string MatchEvalChangeCase( Match match )
{
TextInfo ti = new CultureInfo( "en" ).TextInfo;
if ( itmChangeCaseUppercase.Checked ) return ti.ToUpper( match.Groups[1].Value );
else if( itmChangeCaseLowercase.Checked ) return ti.ToLower( match.Groups[1].Value );
else if( itmChangeCaseTitlecase.Checked ) return ti.ToTitleCase( match.Groups[1].Value.ToLower() );
else return match.Groups[1].Value;
}
示例11: TestTrTRStringWithSymbols
public void TestTrTRStringWithSymbols()
{
string strA = "H\u0131\n\0Hi\u0009!";
string ActualResult;
TextInfo textInfo = new CultureInfo("tr-TR").TextInfo;
ActualResult = textInfo.ToUpper(strA);
Assert.Equal("HI\n\0H\u0130\t!", ActualResult);
}
示例12: TestTrTRNullString
public void TestTrTRNullString()
{
TextInfo textInfoUS = new CultureInfo("tr-TR").TextInfo;
string str = null;
Assert.Throws<ArgumentNullException>(() =>
{
textInfoUS.ToUpper(str);
});
}