เมธอด Char.IsPunctuation() ใน C# บ่งชี้ว่าอักขระ Unicode ที่ระบุจัดอยู่ในประเภทเครื่องหมายวรรคตอน (punctuation mark) หรือไม่
ไวยากรณ์
public static bool IsPunctuation (char ch);
พารามิเตอร์ ch คืออักขระ Unicode ที่ต้องการประเมิน
ตัวอย่าง (ตัวอักษร)
using System;
public class Demo {
public static void Main(){
bool res;
char val = 'q';
Console.WriteLine("Value = " + val);
res = Char.IsPunctuation(val);
Console.WriteLine("Is the value a punctuation? = " + res);
}
}ผลลัพธ์
Value = q Is the value a punctuation? = False
ตัวอย่างที่ 2 (เครื่องหมายจุลภาค)
using System;
public class Demo {
public static void Main(){
bool res;
char val = ',';
Console.WriteLine("Value = " + val);
res = Char.IsPunctuation(val);
Console.WriteLine("Is the value a punctuation? = " + res);
}
}ผลลัพธ์
Value = , Is the value a punctuation? = True