Uri.CheckSchemeName Method

Determines whether the specified scheme name is valid.

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

public static bool CheckSchemeName(
	string schemeName


Type: System.String
The scheme name to validate.

Return Value

Type: System.Boolean
A Boolean value that is true if the scheme name is valid; otherwise, false.

This method checks the scheme name for validity according to RFC 3986. The scheme name must begin with a letter and must contain only letters, digits, and the characters ".", "+", or "-".

The following example creates a Uri instance and checks whether the scheme name is valid.

Uri address3 = new Uri("http://www.contoso.com/index.htm#search");
if (Uri.CheckSchemeName(address1.Scheme))
    outputBlock.Text += "address has a valid scheme name\n";
    outputBlock.Text += "address does not has a valid scheme name\n";

if (address3.Scheme == Uri.UriSchemeHttp)
    outputBlock.Text += "Uri is HTTP type\n";

Uri address1 = new Uri("http://www.contoso.com/index.htm#search");
Console.WriteLine("address 1 {0} a valid scheme name",
      Uri.CheckSchemeName(address1.Scheme) ? " has" : " does not have");

if (address1.Scheme == Uri.UriSchemeHttp)
    Console.WriteLine("Uri is HTTP type");


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

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

Community Additions