Skip to content

Names -> Keywords batch 11 #6974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// <snippet1>
// <snippet1>
using System;

public class GetNumericValueSample {
public static void Main() {
string str = "input: 1";

Console.WriteLine(Char.GetNumericValue('8')); // Output: "8"
Console.WriteLine(Char.GetNumericValue(str, 7)); // Output: "1"
Console.WriteLine(char.GetNumericValue('8')); // Output: "8"
Console.WriteLine(char.GetNumericValue(str, 7)); // Output: "1"
}
}
// </snippet1>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

public class Example
{
Expand All @@ -13,10 +13,10 @@ private static void Overload1()
{
// <Snippet2>
int utf32 = 0x10107; // AEGEAN NUMBER ONE
string surrogate = Char.ConvertFromUtf32(utf32);
string surrogate = char.ConvertFromUtf32(utf32);
foreach (var ch in surrogate)
Console.WriteLine("U+{0:X4}: {1} ", Convert.ToUInt16(ch),
Char.GetNumericValue(ch));
char.GetNumericValue(ch));

// The example displays the following output:
// U+D800: -1
Expand All @@ -30,11 +30,11 @@ private static void Overload2()
// Define a UTF32 value for each character in the
// Aegean numbering system.
for (int utf32 = 0x10107; utf32 <= 0x10133; utf32++) {
string surrogate = Char.ConvertFromUtf32(utf32);
string surrogate = char.ConvertFromUtf32(utf32);
for (int ctr = 0; ctr < surrogate.Length; ctr++)
Console.Write("U+{0:X4} at position {1}: {2} ",
Convert.ToUInt16(surrogate[ctr]), ctr,
Char.GetNumericValue(surrogate, ctr));
char.GetNumericValue(surrogate, ctr));

Console.WriteLine();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// <snippet1>
// <snippet1>
using System;

public class GetUnicodeCategorySample {
public static void Main() {
char ch2 = '2';
string str = "Upper Case";

Console.WriteLine(Char.GetUnicodeCategory('a')); // Output: "LowercaseLetter"
Console.WriteLine(Char.GetUnicodeCategory(ch2)); // Output: "DecimalDigitNumber"
Console.WriteLine(Char.GetUnicodeCategory(str, 6)); // Output: "UppercaseLetter"
Console.WriteLine(char.GetUnicodeCategory('a')); // Output: "LowercaseLetter"
Console.WriteLine(char.GetUnicodeCategory(ch2)); // Output: "DecimalDigitNumber"
Console.WriteLine(char.GetUnicodeCategory(str, 6)); // Output: "UppercaseLetter"
}
}
// </snippet1>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <Snippet2>
// <Snippet2>
using System;

public class ControlChar
Expand All @@ -8,7 +8,7 @@ public static void Main()
string sentence = "This is a " + Environment.NewLine + "two-line sentence.";
for (int ctr = 0; ctr < sentence.Length; ctr++)
{
if (Char.IsControl(sentence, ctr))
if (char.IsControl(sentence, ctr))
Console.WriteLine("Control character \\U{0} found in position {1}.",
Convert.ToInt32(sentence[ctr]).ToString("X4"), ctr);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// <snippet3>
// <snippet3>
using System;

public class IsControlSample {
public static void Main() {
string str = "sample string";

Console.WriteLine(Char.IsControl('\t')); // Output: "True"
Console.WriteLine(Char.IsControl(str, 7)); // Output: "False"
Console.WriteLine(char.IsControl('\t')); // Output: "True"
Console.WriteLine(char.IsControl(str, 7)); // Output: "False"
}
}
// </snippet3>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// <snippet4>
// <snippet4>
using System;

public class IsDigitSample {
public static void Main() {
char ch = '8';

Console.WriteLine(Char.IsDigit(ch)); // Output: "True"
Console.WriteLine(Char.IsDigit("sample string", 7)); // Output: "False"
Console.WriteLine(char.IsDigit(ch)); // Output: "True"
Console.WriteLine(char.IsDigit("sample string", 7)); // Output: "False"
}
}
// </snippet4>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// <snippet5>
// <snippet5>
using System;

public class IsLetterSample {
public static void Main() {
char ch = '8';

Console.WriteLine(Char.IsLetter(ch)); // False
Console.WriteLine(Char.IsLetter("sample string", 7)); // True
Console.WriteLine(char.IsLetter(ch)); // False
Console.WriteLine(char.IsLetter("sample string", 7)); // True
}
}
// </snippet5>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// <snippet6>
// <snippet6>
using System;

public class IsLetterOrDigitSample {
public static void Main() {
string str = "newline:\n";

Console.WriteLine(Char.IsLetterOrDigit('8')); // Output: "True"
Console.WriteLine(Char.IsLetterOrDigit(str, 8)); // Output: "False", because it's a newline
Console.WriteLine(char.IsLetterOrDigit('8')); // Output: "True"
Console.WriteLine(char.IsLetterOrDigit(str, 8)); // Output: "False", because it's a newline
}
}
// </snippet6>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// <snippet7>
// <snippet7>
using System;

public class IsLowerSample {
public static void Main() {
char ch = 'a';

Console.WriteLine(Char.IsLower(ch)); // Output: "True"
Console.WriteLine(Char.IsLower("upperCase", 5)); // Output: "False"
Console.WriteLine(char.IsLower(ch)); // Output: "True"
Console.WriteLine(char.IsLower("upperCase", 5)); // Output: "False"
}
}
// </snippet7>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// <snippet8>
// <snippet8>
using System;

public class IsNumberSample {
public static void Main() {
string str = "non-numeric";

Console.WriteLine(Char.IsNumber('8')); // Output: "True"
Console.WriteLine(Char.IsNumber(str, 3)); // Output: "False"
Console.WriteLine(char.IsNumber('8')); // Output: "True"
Console.WriteLine(char.IsNumber(str, 3)); // Output: "False"
}
}
// </snippet8>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//<Snippet6>
//<Snippet6>
using System;
using System.Globalization;

Expand All @@ -7,10 +7,10 @@ class Example
public static void Main()
{
// Define a string with a variety of character categories.
String s = "The red car drove down the long, narrow, secluded road.";
string s = "The red car drove down the long, narrow, secluded road.";
// Determine the category of each character.
foreach (var ch in s)
Console.WriteLine("'{0}': {1}", ch, Char.GetUnicodeCategory(ch));
Console.WriteLine("'{0}': {1}", ch, char.GetUnicodeCategory(ch));
}
}
// The example displays the following output:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <Snippet1>
// <Snippet1>
using System;
using System.IO;

Expand All @@ -8,7 +8,7 @@ public static void Main()
{
StreamWriter sw = new StreamWriter("chars1.txt");
char[] chars = { '\u0061', '\u0308' };
string strng = new String(chars);
string strng = new string(chars);
sw.WriteLine(strng);
sw.Close();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <Snippet2>
// <Snippet2>
using System;
using System.IO;

Expand All @@ -8,7 +8,7 @@ public static void Main()
{
StreamWriter sw = new StreamWriter(@".\chars2.txt");
int utf32 = 0x1D160;
string surrogate = Char.ConvertFromUtf32(utf32);
string surrogate = char.ConvertFromUtf32(utf32);
sw.WriteLine("U+{0:X6} UTF-32 = {1} ({2}) UTF-16",
utf32, surrogate, ShowCodePoints(surrogate));
sw.Close();
Expand All @@ -18,7 +18,7 @@ private static string ShowCodePoints(string value)
{
string retval = null;
foreach (var ch in value)
retval += String.Format("U+{0:X4} ", Convert.ToUInt16(ch));
retval += string.Format("U+{0:X4} ", Convert.ToUInt16(ch));

return retval.Trim();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// <Snippet3>
// <Snippet3>
using System;

public class Example
{
public static void Main()
{
string result = String.Empty;
string result = string.Empty;
for (int ctr = 0x10107; ctr <= 0x10110; ctr++) // Range of Aegean numbers.
result += Char.ConvertFromUtf32(ctr);
result += char.ConvertFromUtf32(ctr);

Console.WriteLine("The string contains {0} characters.", result.Length);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// <Snippet4>
// <Snippet4>
using System;
using System.Globalization;

public class Example
{
public static void Main()
{
string result = String.Empty;
string result = string.Empty;
for (int ctr = 0x10107; ctr <= 0x10110; ctr++) // Range of Aegean numbers.
result += Char.ConvertFromUtf32(ctr);
result += char.ConvertFromUtf32(ctr);

StringInfo si = new StringInfo(result);
Console.WriteLine("The string contains {0} characters.",
Expand Down