在 C# 中的 Char.IsControl(String, Int32) 方法
C# 中的 Char.IsControl(String, Int32) 方法用于指示指定字符串中指定位置处的字符是否被归类为控制字符。
语法
public static bool IsControl (string str, int index);
上面,str 是一个字符串。index 参数是要在 str 中评估的字符的位置。
现在让我们看一个示例来实现 Char.IsControl(String, Int32) 方法 -
示例
using System;
using System.Globalization;
public class Demo {
public static void Main(){
string val = "hjk9878hj";
Console.WriteLine("String = "+val);
UnicodeCategory unicode = Char.GetUnicodeCategory(val, 4);
Console.WriteLine("The value at specific index = "+unicode);
bool res = Char.IsControl(val, 4);
if (res)
Console.WriteLine("Control character found!");
else
Console.WriteLine("Control character isn't there");
}
}输出
将产生以下输出 -
String = hjk9878hj The value at specific index = DecimalDigitNumber Control character isn't there
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP