由于msdn仅提供部分概述(如here所示),我正在寻找完整的样本,我将在此分享答案。
答案 0 :(得分:3)
此代码的结果
var uri = new Uri("https://images.google.de:80/some/subfolder?someQuery=hi&anotherQUery=there", UriKind.Absolute);
var sb = new StringBuilder();
foreach (UriComponents value in Enum.GetValues(typeof(UriComponents)))
{
sb.AppendLine($"{value} : {uri.GetComponents(value, UriFormat.Unescaped)}");
}
提供了这个结果:
Scheme : https
UserInfo :
Host : images.google.de
Port : 80
SchemeAndServer : https://images.google.de:80
Path : some/subfolder
Query : someQuery=hi&anotherQUery=there
PathAndQuery : /some/subfolder?someQuery=hi&anotherQUery=there
HttpRequestUrl : https://images.google.de:80/some/subfolder?someQuery=hi&anotherQUery=there
Fragment :
AbsoluteUri : https://images.google.de:80/some/subfolder?someQuery=hi&anotherQUery=there
StrongPort : 80
HostAndPort : images.google.de:80
StrongAuthority : images.google.de:80
NormalizedHost : images.google.de
KeepDelimiter :
SerializationInfoString : https://images.google.de:80/some/subfolder?someQuery=hi&anotherQUery=there