C# | Uri.CheckSchemeName(String) Method

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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("http://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");
    }
}

chevron_right


Output:

Scheme name is valid

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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");
    }
}

chevron_right


Output:

Scheme name is valid

Reference:



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.