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:
// 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.w3wiki.net" ); // 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:
- https://docs.microsoft.com/en-us/dotnet/api/system.uri.checkschemename?view=netstandard-2.1
Contact Us