Compartilhar via


Uri.CheckSchemeName Method

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

Determines whether the specified scheme name is valid.

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

Syntax

'Declaration
Public Shared Function CheckSchemeName ( _
    schemeName As String _
) As Boolean
public static bool CheckSchemeName(
    string schemeName
)

Parameters

Return Value

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

Remarks

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 "-".

Examples

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

Dim address3 As Uri = New Uri("https://www.contoso.com/index.htm#search")
If Uri.CheckSchemeName(address1.Scheme) Then 
  outputBlock.Text &= "address has a valid scheme name"
  outputBlock.Text &= vbCrLf
Else    
  outputBlock.Text &= "address does not have a valid scheme name"
  outputBlock.Text &= vbCrLf
End If

If address3.Scheme = Uri.UriSchemeHttp Then
  outputBlock.Text &= "Uri is HTTP type"
  outputBlock.Text &= vbCrLf
End If
Uri address3 = new Uri("https://www.contoso.com/index.htm#search");
if (Uri.CheckSchemeName(address1.Scheme))
    outputBlock.Text += "address has a valid scheme name\n";
else    
    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("https://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");
      

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