第3章 .NET框架类库 - .NET 3.NET [email protected] n...

Info icon This preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
.NET .NET 3 3 .NET .NET [email protected] [email protected]
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
3 .NET .NET 2/34 .NET .NET
Image of page 2
3 .NET .NET 3/34 using System; using System; class App { static void Main() { static void Main() { int int i; i; char c; char c; i = i = Console.Read Console.Read (); (); // // c = (char) i; c = (char) i; Console.WriteLine Console.WriteLine ("Echo: {0}", c); ("Echo: {0}", c); Console.WriteLine Console.WriteLine ("Done"); } }
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
3 .NET .NET 4/34 Char Char char char chA chA = 'A'; = 'A'; char ch1 = '1'; char ch1 = '1'; string str = "test string"; Console.WriteLine(chA.CompareTo('B ')); // Output: // Output: -1 Console.WriteLine(chA.Equals('A Console.WriteLine(chA.Equals('A ')); ')); // Output: True // Output: True Console.WriteLine(Char.GetNumericValue(ch1)); Console.WriteLine(Char.GetNumericValue(ch1)); // Output: 1 // Output: 1 Console.WriteLine(Char.IsControl(' Console.WriteLine(Char.IsControl('\t ')); ')); // Output: True Console.WriteLine(Char.IsDigit(ch1)); // Output: True Console.WriteLine(Char.IsLetter Console.WriteLine(Char.IsLetter (',')); (',')); // Output: False // Output: False Console.WriteLine(Char.IsLower('u Console.WriteLine(Char.IsLower('u ')); ')); // Output: True // Output: True Console.WriteLine(Char.IsNumber(ch1)); // Output: True Console.WriteLine(Char.IsPunctuation ('.')); // Output: True Console.WriteLine(Char.IsSeparator(str Console.WriteLine(Char.IsSeparator(str , 4)); , 4)); // Output: True // Output: True Console.WriteLine(Char.IsSymbol Console.WriteLine(Char.IsSymbol ('+')); ('+')); // Output: True // Output: True Console.WriteLine(Char.IsWhiteSpace(str , 4)); // Output: True Console.WriteLine(Char.Parse("S ")); // Output: S Console.WriteLine(Char.ToLower('M ')); // Output: m Console.WriteLine('x'.ToString Console.WriteLine('x'.ToString ()); ()); // Output: x // Output: x
Image of page 4
3 .NET .NET 5/34 Char Char C# C# using System; using System; class App { static void Main() { static void Main() { char c; char c; int n; int n; c = (char)65; c = (char)65; Console.WriteLine(c Console.WriteLine(c ); ); // // ”A” n = ( n = ( int)c int)c; Console.WriteLine(n Console.WriteLine(n ); ); // 65 65” c = unchecked((char)(65536 + 65)); c = unchecked((char)(65536 + 65)); Console.WriteLine(c Console.WriteLine(c ); ); // // ”A” } }
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
3 .NET .NET 6/34 Char Char Convert Convert using System; using System; class App { static void Main() { static void Main() { char c; char c; int n; int n; c = Convert.ToChar(65); c = Convert.ToChar(65); Console.WriteLine(c Console.WriteLine(c ); ); // // ”A” n = Convert.ToInt32(c); n = Convert.ToInt32(c); Console.WriteLine(n Console.WriteLine(n ); ); // 65 65” } }
Image of page 6