要指示指定的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