Computer >> 컴퓨터 >  >> 프로그램 작성 >> C#

C#의 Uri.IsHexEncoding() 메서드

<시간/>

C#의 Uri.IsHexEncoding() 메서드는 문자열의 문자가 16진수로 인코딩되었는지 여부를 결정합니다.

구문

다음은 구문입니다 -

public static bool IsHexEncoding (string pattern, int index);

위에서 pattern 매개변수는 확인할 문자열이고 index는 16진수 인코딩을 확인할 패턴의 위치입니다.

예시

이제 Uri.IsHexEncoding() 메서드를 구현하는 예를 살펴보겠습니다. -

using System;
public class Demo {
   public static void Main(){
      string pattern = "%50";
      bool res = Uri.IsHexEncoding(pattern, 0);
      if (res)
         Console.WriteLine("Valid: Hexadecimal Encoded");
      else
         Console.WriteLine("Invalid: Hexadecimal Encoded");
   }
}

출력

이것은 다음과 같은 출력을 생성합니다 -

Valid: Hexadecimal Encoded

예시

이제 Uri.IsHexEncoding() 메서드를 구현하는 또 다른 예를 살펴보겠습니다.

using System;
public class Demo {
   public static void Main(){
      string pattern = "%60";
      bool res = Uri.IsHexEncoding(pattern, 1);
      if (res)
         Console.WriteLine("Valid: Hexadecimal Encoded");
      else
         Console.WriteLine("Invalid: Hexadecimal Encoded");
   }
}

출력

이것은 다음과 같은 출력을 생성합니다 -

Invalid: Hexadecimal Encoded