Uri.IsBaseOf(Uri) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
public:
bool IsBaseOf(Uri ^ uri);
public bool IsBaseOf(Uri uri);
member this.IsBaseOf : Uri -> bool
Public Function IsBaseOf (uri As Uri) As Boolean
参数
- uri
- Uri
要测试的指定 URI。
返回
true 如果当前 Uri 实例是基实例, uri则为 ;否则为 false。
例外
uri 是 null。
示例
此示例创建一个 Uri 表示基 Uri 实例的实例。 然后,它从字符串创建第二 Uri 个实例。 它调用 IsBaseOf 以确定基实例是否为第二个实例的基实例。 结果将写入控制台。
// Create a base Uri.
Uri baseUri = new Uri("http://www.contoso.com/");
// Create a new Uri from a string.
Uri uriAddress = new Uri("http://www.contoso.com/index.htm?date=today");
// Determine whether BaseUri is a base of UriAddress.
if (baseUri.IsBaseOf(uriAddress))
Console.WriteLine("{0} is the base of {1}", baseUri, uriAddress);
// Create a base Uri.
let baseUri = Uri "http://www.contoso.com/"
// Create a new Uri from a string.
let uriAddress = Uri "http://www.contoso.com/index.htm?date=today"
// Determine whether BaseUri is a base of UriAddress.
if baseUri.IsBaseOf uriAddress then
printfn $"{baseUri} is the base of {uriAddress}"
' Create a base Uri.
Dim baseUri As New Uri("http://www.contoso.com/")
' Create a new Uri from a string.
Dim uriAddress As New Uri("http://www.contoso.com/index.htm?date=today")
' Determine whether BaseUri is a base of UriAddress.
If baseUri.IsBaseOf(uriAddress) Then
Console.WriteLine("{0} is the base of {1}", baseUri, uriAddress)
End If
注解
IsBaseOf 用于将当前 Uri 实例与指定 Uri 实例进行比较,以确定此 URI 是否为指定 UriURI 的基。 比较两 Uri 个对象以确定基本关系时,不会评估用户信息(UserInfo)。 比较两个 URI(uri1 和 uri2)时,uri1 是 uri2 的基数(如果忽略 uri1 和 uri2 中最后一个斜杠 (/), uri2 以确切 URI1 开头。 使用 http://host/path/path/file?query 基 URI 时,下表显示它是否是其他 URI 的基础。
| URI | http://host/path/path/file?query 是基数 |
|---|---|
| http://host/path/path/file/ | 是的 |
| http://host/path/path/#fragment | 是的 |
| http://host/path/path/MoreDir/" | 是的 |
| http://host/path/path/OtherFile?Query | 是的 |
| http://host/path/path/ | 是的 |
| http://host/path/path/file | 是的 |
| http://host/path/path | 否 |
| http://host/path/path?query | 否 |
| http://host/path/path#Fragment | 否 |
| http://host/path/path2/ | 否 |
| ://host/path/path2/MoreDir | 否 |
| http://host/path/File | 否 |