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://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://tutorialspoint.com/index.htm URI = https://tutorialspoint.com/ Both the URIs aren't equal! newURI1 is well formed!
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP