指示指定的Unicode字符在C#中是否为空格
要指示指定的Unicode字符是否为空格,代码如下-
示例
using System;
public class Demo {
public static void Main() {
bool res;
char val = ' ';
Console.WriteLine("Value = "+val);
res = Char.IsWhiteSpace(val);
Console.WriteLine("Is the value whitespace? = "+res);
}
}输出结果
这将产生以下输出-
Value = Is the value whitespace? = True
示例
让我们看另一个例子-
using System;
public class Demo {
public static void Main() {
bool res;
char val = 'm';
Console.WriteLine("Value = "+val);
res = Char.IsWhiteSpace(val);
Console.WriteLine("Is the value whitespace? = "+res);
}
}输出结果
这将产生以下输出-
Value = m Is the value whitespace? = False