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

C#의 Uri.IsWellFormedOriginalString() 메서드

<시간/>

C#의 Uri.IsWellFormedOriginalString() 메서드는 이 Uri를 구성하는 데 사용된 문자열이 올바른 형식으로 되어 있고 더 이상 이스케이프할 필요가 없는지 여부를 나타냅니다.

구문

다음은 구문입니다 -

public bool IsWellFormedOriginalString ();

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

using System;
public class Demo {
   public static void Main(){
      Uri newURI1 = new Uri("https://www.tutorialspoint.com/index.htm");
      Console.WriteLine("URI = "+newURI1);
      Uri newURI2 = new Uri("https://www.qries.com/");
      Console.WriteLine("URI = "+newURI2);
      if(newURI1.Equals(newURI2))
         Console.WriteLine("Both the URIs are equal!");
      else
         Console.WriteLine("Both the URIs aren't equal!");
      if(newURI1.IsWellFormedOriginalString())
         Console.WriteLine("newURI1 is well formed!");
      else
         Console.WriteLine("newURI1 isn't well formed!");
   }
}

출력

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

URI = https://www.tutorialspoint.com/index.htm
URI = https://www.tutorialspoint.com/
Both the URIs aren't equal!
newURI1 is well formed!