Uri.CheckSchemeName(String) Method in C#


The Uri.CheckSchemeName() method in C# is used to determine whether the specified scheme name is valid.

syntax

Following is the syntax −

public static bool CheckSchemeName (string schemeName);

Above, the parameter scheme name is the scheme name to validate.

Example

Let us now see an example to implement the Uri.CheckSchemeName() method −

using System;
public class Demo {
   public static void Main(){
      Uri newURI = new Uri("https://www.tutorialspoint.com");
      Console.WriteLine("URI = "+newURI);
      string schemeName = newURI.Scheme;
      if(Uri.CheckSchemeName(schemeName))
         Console.WriteLine("Valid: Scheme name");
      else
         Console.WriteLine("Invalid: Scheme name");
   }
}

Output

This will produce the following output −

URI = https://www.tutorialspoint.com/
Valid: Scheme name

Example

Let us now see another example to implement the Uri.CheckSchemeName() method −

using System;
public class Demo {
   public static void Main(){
      Uri newURI = new Uri("https://www.tutorialspoint.com/index.htm");
      Console.WriteLine("URI = "+newURI);
      string schemeName = newURI.Scheme;
      if(Uri.CheckSchemeName(schemeName))
         Console.WriteLine("Valid: Scheme name");
      else
         Console.WriteLine("Invalid: Scheme name");
   }
}

Output

This will produce the following output −

URI = https://www.tutorialspoint.com/index.htm
Valid: Scheme name

Updated on: 13-Nov-2019

65 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements