UriParser.GetComponents(Uri, UriComponents, UriFormat) UriParser.GetComponents(Uri, UriComponents, UriFormat) UriParser.GetComponents(Uri, UriComponents, UriFormat) Method

定义

从 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 Uri

要分析的 URI。The URI to parse.

components
UriComponents UriComponents UriComponents

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

format
UriFormat UriFormat 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,如SchemeHost,或PortUse 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.

适用于

另请参阅