Uri.IsBaseOf(Uri) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
The specified URI to test.
true
if the current Uri instance is a base of uri
; otherwise, false
.
uri
is null
.
This example creates a Uri instance that represents a base Uri instance. It then creates a second Uri instance from a string. It calls IsBaseOf to determine whether the base instance is the base of the second instance. The outcome is written to the console.
// Create a base Uri.
Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" );
// Create a new Uri from a string.
Uri^ uriAddress = gcnew 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.
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 is used to compare the current Uri instance to a specified Uri to determine whether this URI is a base for the specified Uri. When comparing two Uri objects to determine a base relationship, the user information (UserInfo) is not evaluated. When comparing two URIs (uri1 and uri2), uri1 is the base of uri2 if, when you ignore everything in uri1 and uri2 after the last slash (/), uri2 starts with exactly uri1. Using http://host/path/path/file?query as the base URI, the following table shows whether it is a base for other URIs.
URI | http://host/path/path/file?query is base of |
---|---|
http://host/path/path/file/ | yes |
http://host/path/path/#fragment | yes |
http://host/path/path/MoreDir/" | yes |
http://host/path/path/OtherFile?Query | yes |
http://host/path/path/ | yes |
http://host/path/path/file | yes |
http://host/path/path | no |
http://host/path/path?query | no |
http://host/path/path#Fragment | no |
http://host/path/path2/ | no |
://host/path/path2/MoreDir | no |
http://host/path/File | no |
제품 | 버전 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET 피드백
.NET은(는) 오픈 소스 프로젝트입니다. 다음 링크를 선택하여 피드백을 제공해 주세요.