Computer >> Computer tutorials >  >> Programming >> C#

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