C# 中的 Char.IsSymbol() 方法
csharpprogrammingserver side programming更新于 2025/9/20 9:48:00
C# 中的 Char.IsSymbol() 方法指示指定字符串中指定位置的字符是否属于符号字符。
语法
public static bool IsSymbol (string str, int index);
上面,str 是一个字符串,而要评估的字符在 str 中的位置。
现在让我们看一个实现 Char.IsSymbol() 方法的示例 −
示例
using System;
public class Demo {
public static void Main(){
bool res;
char val = 'P';
Console.WriteLine("Value = "+val);
res = Char.IsSymbol(val);
Console.WriteLine("Is the value a symbol? = "+res);
}
}
输出
这将产生以下输出 −
Value = P Is the value a symbol? = False
让我们看另一个例子 −
示例
using System;
public class Demo {
public static void Main(){
bool res;
char val = '+';
Console.WriteLine("Value = "+val);
res = Char.IsSymbol(val);
Console.WriteLine("Is the value a symbol? = "+res);
}
}
输出
这将产生以下输出 −
Value = + Is the value a symbol? = True

