Export (0) Print
Expand All

Uri Constructor (String)

.NET Framework 1.1

Initializes a new instance of the Uri class with the specified URI.

[Visual Basic]
Public Sub New( _
   ByVal uriString As String _
)
[C#]
public Uri(
   string uriString
);
[C++]
public: Uri(
   String* uriString
);
[JScript]
public function Uri(
   uriString : String
);

Parameters

uriString
A URI.

Exceptions

Exception Type Condition
ArgumentNullException uriString is a null reference (Nothing in Visual Basic).
UriFormatException uriString is empty.

-or-

The scheme specified in uriString is invalid.

-or-

uriString contains too many slashes.

-or-

The password specified in uriString is invalid.

-or-

The host name specified in uriString is invalid.

-or-

The file name specified in uriString is invalid.

Remarks

This constructor creates a Uri instance from a URI string. It parses the URI, puts it in canonical format, and makes any required escape encodings.

Example

The following example creates a Uri instance with the URI "http://www.contoso.com/".

[Visual Basic] 
Dim myUri As New Uri("http://www.contoso.com/")


[C#] 
Uri myUri = new Uri("http://www.contoso.com/");


[C++] 
Uri* baseUri = new Uri(S"http://www.contoso.com/");

[JScript] 
var myUri : Uri = new Uri("http://www.contoso.com/");

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Uri Class | Uri Members | System Namespace | Uri Constructor Overload List

Show:
© 2014 Microsoft