C# 中的 Char.IsLetterOrDigit() 方法
C# 中的 Char.IsLetterOrDigit() 方法指示指定的 Unicode 字符是否分类为字母或十进制数字。
语法
以下是语法 −
public static bool IsLetterOrDigit (char ch);
上面的 ch 是要评估的 Unicode 字符。
示例
现在让我们看一个示例来实现 Char.IsLetterOrDigit() 方法 −
using System;
public class Demo {
public static void Main(){
bool res;
char val = '1';
Console.WriteLine("Value = "+val);
res = Char.IsLetterOrDigit(val);
Console.WriteLine("Is the value a letter or digit? = "+res);
}
}输出
这将产生以下输出 −
Value = 1 Is the value a letter or digit? = True
示例
现在我们再看一个示例 −
using System;
public class Demo {
public static void Main(){
bool res;
char val = '$';
Console.WriteLine("Value = "+val);
res = Char.IsLetterOrDigit(val);
Console.WriteLine("Is the value a letter or digit? = "+res);
}
}输出
这将产生以下输出 −
Value = $ Is the value a letter or digit? = False
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
安卓
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP