C#| Char。IsSymbol()方法

在C#中, 烧焦IsSymbol() 是一个 系统烧焦 struct方法,用于检查Unicode字符是否是在下定义的有效符号 单十范畴 数学符号 , 货币符号 , 修饰符号 其他符号 或者不是。通过向该方法传递不同类型和数量的参数,可以重载该方法。

null

  1. 烧焦IsSymbol(字符)方法
  2. 烧焦IsSymbol(字符串,Int32)方法

烧焦IsSymbol(字符)方法

此方法用于检查指定的Unicode字符是否与Unicode类别中的任何有效符号匹配。如果匹配,则返回True,否则返回False。

语法:

public static bool IsSymbol(char ch);

参数:

中国 :它是的unicode字符所必需的 系统烧焦 键入要检查的有效符号。

返回类型: 如果指定的Unicode字符是有效符号,则该方法返回True,否则返回False。此方法的返回类型为 系统布尔型。

例子:

// C# program to illustrate the
// Char.IsSymbol(Char) Method
using System;
class GFG {
// Main Method
static public void Main()
{
// Declaration of data type
bool result;
// checking if plus sign
// is symbol or not
char ch1 = '+' ;
result = Char.IsSymbol(ch1);
Console.WriteLine(result);
// checking if dollar sign
// is symbol or not
char ch2 = '$' ;
result = Char.IsSymbol(ch2);
Console.WriteLine(result);
// checking if @
// is symbol or not
char ch3 = '@' ;
result = Char.IsSymbol(ch3);
Console.WriteLine(result);
}
}


输出:

True
True
False

烧焦IsSymbol(字符串,Int32)方法

此方法用于检查指定位置的指定字符串中的字符是否为有效符号。如果它是符合Unicode标准的符号,则返回True,否则返回False。

语法:

public static bool IsSymbol(string str, int index);

参数:

Str: 这是所需的字符串 系统一串 键入要检查的字符。 索引: 它是字符在指定字符串中的位置。此参数的类型为 系统Int32 .

返回类型: 如果指定字符串中指定索引处的字符是符合Unicode标准的有效符号,则该方法返回True,否则返回False。此方法的返回类型为 系统布尔值 .

例子:

// C# program to illustrate the
// Char.IsSymbol(String, Int32) Method
using System;
class GFG {
// Main Method
static public void Main()
{
// Declaration of data type
bool result;
// checking for symbol in
// a string
string str1 = "www.GeeksforGeeks.org" ;
result = Char.IsSymbol(str1, 3);
Console.WriteLine(result);
// checking for symbol in
// a string
string str2 = "geeks+" ;
result = Char.IsSymbol(str2, 5);
Console.WriteLine(result);
}
}


输出:

False
True

参考: https://docs.microsoft.com/en-us/dotnet/api/system.char.issymbol?view=netframework-4.7.2

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享