Uri.IsBaseOf(Uri) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
public:
bool IsBaseOf(Uri ^ uri);
public bool IsBaseOf(Uri uri);
member this.IsBaseOf : Uri -> bool
Public Function IsBaseOf (uri As Uri) As Boolean
Parametrar
- uri
- Uri
Den angivna URI:n som ska testas.
Returer
true om den aktuella Uri instansen är en bas av uri, annars , false.
Undantag
uri är null.
Exempel
Det här exemplet skapar en Uri instans som representerar en basinstans Uri . Sedan skapas en andra Uri instans från en sträng. Den anropar IsBaseOf för att avgöra om basinstansen är basen för den andra instansen. Resultatet skrivs till konsolen.
// 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
Kommentarer
IsBaseOf används för att jämföra den aktuella Uri instansen med en angiven Uri för att avgöra om den här URI:n är en bas för den angivna Uri. När du jämför två Uri objekt för att fastställa en basrelation utvärderas inte användarinformationen (UserInfo). När du jämför två URI:er (uri1 och uri2) är uri1 basen för uri2 om uri2 börjar med exakt uri1 när du ignorerar allt i uri1 och uri2 efter det senaste snedstrecket (/). I http://host/path/path/file?query följande tabell används som bas-URI och visar om det är en bas för andra URI:er.
| URI | http://host/path/path/file?query är basen för |
|---|---|
| http://host/path/path/file/ | Ja |
| http://host/path/path/#fragment | Ja |
| http://host/path/path/MoreDir/" | Ja |
| http://host/path/path/OtherFile?Query | Ja |
| http://host/path/path/ | Ja |
| http://host/path/path/file | Ja |
| http://host/path/path | Nej |
| http://host/path/path?query | Nej |
| http://host/path/path#Fragment | Nej |
| http://host/path/path2/ | Nej |
| ://host/path/path2/MoreDir | Nej |
| http://host/path/File | Nej |