วิธี Char.IsUpper() ใน C# ระบุว่าอักขระ Unicode ที่ระบุถูกจัดประเภทเป็นตัวพิมพ์ใหญ่หรือไม่
ไวยากรณ์
public static bool IsUpper (char ch);
ด้านบน พารามิเตอร์ ch คืออักขระ Unicode ที่จะประเมิน
ให้เราดูตัวอย่างการใช้วิธี Char.IsUpper() -
ตัวอย่าง
using System;
public class Demo {
public static void Main(){
bool res;
char val = 'H';
Console.WriteLine("Value = "+val);
res = Char.IsUpper(val);
Console.WriteLine("Is the value an uppercae letter? = "+res);
}
} ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
Value = H Is the value an uppercae letter? = True
ให้เราดูตัวอย่างอื่นเพื่อใช้วิธีการ IsUpper() -
ตัวอย่าง
using System;
public class Demo {
public static void Main(){
bool res;
char val = 'j';
Console.WriteLine("Value = "+val);
res = Char.IsUpper(val);
Console.WriteLine("Is the value an uppercae letter? = "+res);
}
} ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
Value = j Is the value an uppercae letter? = False