C#中的Char.IsPunctuation()方法

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