c# - 是否有一个概述来查看哪些 UriComponents 返回 Uri 的内容?

标签 c# uri

由于 msdn 仅提供了部分概述(如 here 所示),并且我一直在寻找完整的示例,因此我将在这里分享答案。

最佳答案

这段代码的结果

        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

关于c# - 是否有一个概述来查看哪些 UriComponents 返回 Uri 的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44261401/

相关文章:

javascript - 使用 iTextSharp 将 javascript 添加到 pdf 文件

c# - 框架类库(FCL) 是分别为C# 和C++ 实现的吗?

c# - 网络摄像头:打开和关闭或或保持打开

Android:如何将文件 Uri 转换为内容 Uri

android - 从 Intent 中获取音频uri

http - 主机名和 IP 地址的常用术语?

c# - 程序应该给一个单词特殊的数值(但是......)

c# - 如何在 Linq 中进行汇总?

android - app 和 uri 的内部存储

zend-framework - 在 zend 框架中正确使用语言