C# | Char.IsSymbol() Method
Last Updated :
31 Jan, 2019
In C#, Char.IsSymbol() is a System.Char struct method which is used to check whether a Unicode character is a valid symbol defined under UnicodeCategory as MathSymbol, CurrencySymbol, ModifierSymbol, or OtherSymbol or not. This method can be overloaded by passing different types and number of arguments to it.
- Char.IsSymbol(Char) Method
- Char.IsSymbol(String, Int32) Method
Char.IsSymbol(Char) Method
This method is used to check whether a specified Unicode character matches with any valid symbol in UnicodeCategory or not. If it matches then it returns True otherwise return False.
Syntax:
public static bool IsSymbol(char ch);
Parameter:
ch: It is required unicode character of System.char type which is to be checked for a valid symbol.
Return Type: The method returns True if the specified Unicode character is a valid symbol, otherwise returns False. The return type of this method is System.Boolean.
Example:
using System;
class GFG {
static public void Main()
{
bool result;
char ch1 = '+' ;
result = Char.IsSymbol(ch1);
Console.WriteLine(result);
char ch2 = '$' ;
result = Char.IsSymbol(ch2);
Console.WriteLine(result);
char ch3 = '@' ;
result = Char.IsSymbol(ch3);
Console.WriteLine(result);
}
}
|
Char.IsSymbol(String, Int32) Method
This method is used to check whether a character in the specified string at the specified position is a valid symbol or not. If it is a symbol according to the Unicode standard then it returns True otherwise returns False.
Syntax:
public static bool IsSymbol(string str, int index);
Parameters:
Str: It is the required string of System.Stringtype whose character is to be checked.
index: It is the position of character in specified string. Type of this parameter is System.Int32.
Return Type: The method returns True if the character at specified index in the specified string is a valid symbol according to the Unicode standard, otherwise returns False. The return type of this method is System.Boolean.
Example:
using System;
class GFG {
static public void Main()
{
bool result;
string str1 = "www.GeeksforGeeks.org" ;
result = Char.IsSymbol(str1, 3);
Console.WriteLine(result);
string str2 = "geeks+" ;
result = Char.IsSymbol(str2, 5);
Console.WriteLine(result);
}
}
|
Reference: https://docs.microsoft.com/en-us/dotnet/api/system.char.issymbol?view=netframework-4.7.2
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...