Export (0) Print
Expand All

Uri.GetComponents Method

Note: This method is new in the .NET Framework version 2.0.

Gets the specified components of the current instance using the specified escaping for special characters.

Namespace: System
Assembly: System (in system.dll)

public string GetComponents (
	UriComponents components,
	UriFormat format
)
public String GetComponents (
	UriComponents components, 
	UriFormat format
)
public function GetComponents (
	components : UriComponents, 
	format : UriFormat
) : String

Parameters

components

A bitwise combination of the UriComponents values that specifies which parts of the current instance to return to the caller.

format

One of the UriFormat values that controls how special characters are escaped.

Return Value

A string containing the components.

Exception typeCondition

ArgumentOutOfRangeException

uriComponents is not a combination of valid UriComponents values.

InvalidOperationException

The current Uri is not an absolute URI. Relative URIs cannot be used with this method.

When Query or Fragment is specified alone, the return value includes the delimiter. The Scheme, UserInfo, Host, Port, and Path components do not include the delimiter. For all other UriComponents values, and combinations of values, the delimiters are included in the returned value.

The components are returned in the order that they appear in the URI. For example, if Scheme is specified, it appears first.

NoteNote

If the GetComponents method is called with format set to Unescaped , you cannot use the return value as an argument to a a Uri constructor to create an equivalent Uri.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft