Uri.GetComponents Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

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

Syntax

'Declaration
Public Function GetComponents ( _
    components As UriComponents, _
    format As UriFormat _
) As String
public string GetComponents(
    UriComponents components,
    UriFormat format
)

Parameters

  • components
    Type: System.UriComponents
    A bitwise combination of the UriComponents values that specifies which parts of the current instance to return to the caller.

Return Value

Type: System.String
A String that contains the components.

Exceptions

Exception Condition
ArgumentOutOfRangeException

uriComponents is not a combination of valid UriComponents values.

InvalidOperationException

This method is valid only for an absolute Uri instance.

Remarks

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 Uri constructor to create an equivalent Uri.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference