วิธี Char.GetUnicodeCategory(String, Int32) ใน C# จัดหมวดหมู่อักขระที่ตำแหน่งที่ระบุในสตริงที่ระบุเป็นกลุ่มที่ระบุโดยค่า UnicodeCategory ค่าใดค่าหนึ่ง
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
public static System.Globalization.UnicodeCategory GetUnicodeCategory (string str, int index);
ด้านบน str คือสตริง ในขณะที่ดัชนีคือตำแหน่งอักขระใน str
ตัวอย่าง
ให้เราดูตัวอย่างการใช้งานวิธี Char.GetUnicodeCategory(String, Int32) -
using System;
using System.Globalization;
public class Demo {
public static void Main(){
string val = "amit";
UnicodeCategory unicode = Char.GetUnicodeCategory(val, 2);
Console.WriteLine("The value at specific index = "+unicode);
}
} ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
LowercaseLetter
ตัวอย่าง
เรามาดูตัวอย่างอื่นกัน −
using System;
using System.Globalization;
public class Demo {
public static void Main(){
string val = "hjk9878hj";
UnicodeCategory unicode = Char.GetUnicodeCategory(val, 4);
Console.WriteLine("The value at specific index = "+unicode);
}
} ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
The value at specific index = DecimalDigitNumber