The Char.IsControl(String, Int32) method in C# is used to indicate whether the character at the specified position in a specified string is categorized as a control character.
Syntax
public static bool IsControl (string str, int index);
Above, str is a string. The index parameter is the position of the character to evaluate in str.
Let us now see an example to implement the Char.IsControl(String, Int32) method −
Example
using System;
using System.Globalization;
public class Demo {
public static void Main(){
string val = "hjk9878hj";
Console.WriteLine("String = "+val);
UnicodeCategory unicode = Char.GetUnicodeCategory(val, 4);
Console.WriteLine("The value at specific index = "+unicode);
bool res = Char.IsControl(val, 4);
if (res)
Console.WriteLine("Control character found!");
else
Console.WriteLine("Control character isn't there");
}
}Output
This will produce the following output −
String = hjk9878hj The value at specific index = DecimalDigitNumber Control character isn't there