Csharp/CSharp Tutorial/String/String Case — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 15:31, 26 мая 2010
Case Comparison
using System;
class Class1
{
[STAThread]
static void Main(string[] args)
{
char smallA = "a";
char largeA = "A";
Console.WriteLine( "a = {0} A = {1}", (int) smallA, (int) largeA );
string str1 = "This Is A String.";
string str2 = "This is a string.";
Console.WriteLine( "Case sensitive comparison of str1 and str2 = {0}", String.rupare( str1, str2 ));
Console.WriteLine( "Case insesitive comparison of str1 and str2 = {0}", String.rupare( str1, str2, true ));
}
}
Create upper and lowercase versions of a string
using System;
class MainClass {
public static void Main() {
string str1 = "ABCDEabcde1234567890";
string strLow = str1.ToLower();
string strUp = str1.ToUpper();
Console.WriteLine("Lowercase version of str1:\n " + strLow);
Console.WriteLine("Uppercase version of str1:\n " + strUp);
}
}
Lowercase version of str1: abcdeabcde1234567890 Uppercase version of str1: ABCDEABCDE1234567890