在 C# 中检查指定 Unicode 字符是否为标点符号
要检查指定的 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
示例
我们来看另一个示例 −
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
广告