C#의 Char.IsControl(String, Int32) 메서드는 지정된 문자열의 지정된 위치에 있는 문자가 제어 문자로 분류되는지 여부를 나타내는 데 사용됩니다.
구문
public static bool IsControl (string str, int index);
위의 str은 문자열입니다. 인덱스 매개변수는 str에서 평가할 문자의 위치입니다.
이제 Char.IsControl(String, Int32) 메서드를 구현하는 예를 살펴보겠습니다. -
예
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");
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
String = hjk9878hj The value at specific index = DecimalDigitNumber Control character isn't there