UriParser.GetComponents(Uri, UriComponents, UriFormat) 方法

定义

从 URI 获取各个组成部分。Gets the components from a URI.

protected:
 virtual System::String ^ GetComponents(Uri ^ uri, UriComponents components, UriFormat format);
protected virtual string GetComponents (Uri uri, UriComponents components, UriFormat format);
abstract member GetComponents : Uri * UriComponents * UriFormat -> string
override this.GetComponents : Uri * UriComponents * UriFormat -> string

参数

uri
Uri

要分析的 URI。The URI to parse.

components
UriComponents

要从 UriComponents 中检索的 uriThe UriComponents to retrieve from uri.

format
UriFormat

UriFormat 值中的一个,它控制如何转义特殊字符。One of the UriFormat values that controls how special characters are escaped.

返回

包含组成部分的字符串。A string that contains the components.

异常

uriFormat 无效。uriFormat is invalid.

- 或 --or- uriComponents 不是有效 UriComponents 值的组合。uriComponents is not a combination of valid UriComponents values.

uri 需要用户驱动的语法分析uri requires user-driven parsing - 或 --or- uri 不是绝对 URI。uri is not an absolute URI. 相对 URI 不能和此方法一起使用。Relative URIs cannot be used with this method.

注解

使用 GetComponents 方法来确定 URI 的各个部分的值,如 SchemeHostPortUse the GetComponents method to determine the value of various parts of the URI, such as the Scheme, Host, or Port.

组件按照其在 URI 中出现的顺序返回。The components are returned in the order that they appear in the URI. 例如,如果指定了 Scheme,则将首先显示它。For example, if Scheme is specified, it appears first.

适用于

另请参阅