C# 中的 Char.IsPunctuation() 方法
csharpserver side programmingprogramming更新于 2025/9/18 6:45:00
C# 中的 Char.IsPunctuation() 方法指示指定的 Unicode 字符是否属于标点符号。
语法
以下是语法 −
public static bool IsPunctuation (char ch);
上面,ch 是要评估的 Unicode 字符。
示例
现在让我们看一个实现 Char.IsPunctuation() 方法的示例 −
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
示例
现在让我们看另一个例子 −
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

