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

定义

使用特殊字符的指定转义,获取当前实例的指定部分。Gets the specified components of the current instance using the specified escaping for special characters.

public:
 System::String ^ GetComponents(UriComponents components, UriFormat format);
public string GetComponents (UriComponents components, UriFormat format);
member this.GetComponents : UriComponents * UriFormat -> string
Public Function GetComponents (components As UriComponents, format As UriFormat) As String

参数

components
UriComponents UriComponents UriComponents UriComponents

UriComponents 值的按位组合,它指定当前实例中要返回到调用方的部分。A bitwise combination of the UriComponents values that specifies which parts of the current instance to return to the caller.

format
UriFormat UriFormat UriFormat UriFormat

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

返回

一个包含这些部分的 StringA String that contains the components.

异常

components 不是有效 UriComponents 值的组合。components is not a combination of valid UriComponents values.

当前 Uri 不是绝对 URI。The current Uri is not an absolute URI. 相对 URI 不能和此方法一起使用。Relative URIs cannot be used with this method.

注解

QueryFragmentSchemeUserInfoHostPort,和Path组件不包含分隔符。The Query, Fragment, Scheme, UserInfo, Host, Port, and Path components do not include the delimiter. 你可以组合KeepDelimiter任何这些值来获取具有分隔符的值 (使用按位 OR 运算符) 的标志。You can combine the KeepDelimiter flag (using the bitwise OR operator) with any of those values to get the value with the delimiter. 对于所有其他UriComponents值和的值组合,分隔符会包括在返回的值。For all other UriComponents values, and combinations of values, the delimiters are included in the returned value.

组件是它们在 URI 中显示的顺序返回。The components are returned in the order that they appear in the URI. 例如,如果Scheme指定,则它显示在最前面。For example, if Scheme is specified, it appears first.

在中启用国际资源标识符 (IRI) 和国际化域名 (IDN) 支持后,返回的字符数String会增加。When International Resource Identifier (IRI) and Internationalized Domain Name (IDN) support are enabled, the number of characters returned in the String increases. 用于支持 IRI Punycode 名称只能包含 ASCII 字符,并且始终以 xn--前缀开头。Punycode names used to support IRI contain only ASCII characters and always start with the xn-- prefix. 启用 IRI 和 IDN,正确处理 Unicode 代理项字符GetComponents方法。When IRI and IDN are enabled, Unicode surrogate characters are handled correctly by the GetComponents method.

IRI 支持的详细信息,请参阅备注部分Uri类。For more information on IRI support, see the Remarks section for the Uri class.

备注

如果GetComponents与调用方法format设置为Unescaped,不能使用返回的值作为参数Uri构造函数创建等效UriIf the GetComponents method is called with format set to Unescaped , you cannot use the return value as an argument to a Uri constructor to create an equivalent Uri.

适用于