Open In App

C# | Uri.CheckSchemeName(String) Method

Last Updated : 01 May, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

Uri.CheckSchemeName(String) Method is used to determine whether the specified scheme name is valid or not.

Syntax: public static bool CheckSchemeName (string schemeName);
Here, it takes the scheme name to validate.

Return Value: This method returns a Boolean value true if the scheme name is valid otherwise, false.

Below programs illustrate the use of Uri.CheckSchemeName() Method:

Example 1:




// C# program to demonstrate the
// Uri.CheckSchemeName(string) Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
        // Declaring and initializing Uri
        Uri uri = new Uri("https://www.geeksforgeeks.org");
  
        // Determining the Scheme of the Uri
        string scheme = uri.Scheme;
  
        // using CheckSchemeName() method
        bool value = Uri.CheckSchemeName(scheme);
  
        // Displaying the result
        if (value)
            Console.WriteLine("Scheme name is valid");
        else
            Console.WriteLine("Scheme name is invalid");
    }
}


Output:

Scheme name is valid

Example 2:




// C# program to demonstrate the
// Uri.CheckSchemeName(string) Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
        // Declaring and initializing Uri
        Uri uri = new Uri("https://www.pierobon.org/iis/review1.htm.html#one");
  
        // Determining the Scheme of the Uri
        string scheme = uri.Scheme;
  
        // using CheckSchemeName() method
        bool value = Uri.CheckSchemeName(scheme);
  
        // Displaying the result
        if (value)
            Console.WriteLine("Scheme name is valid");
        else
            Console.WriteLine("Scheme name is invalid");
    }
}


Output:

Scheme name is valid

Reference:



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads