Home »
C#
C# | Uri.IsHexEncoding() Method with Example
Uri.IsHexEncoding() Method: Here, we are going to learn about the IsHexEncoding() method of Uri class with example in C#.
Submitted by Nidhi, on March 26, 2020
Uri.IsHexEncoding() Method
Uri.IsHexEncoding() method is a static method or Uri class. Which is used to return that given string is hex-encoded or not? If the given string is hex coded then it returns true otherwise it returns false.
Syntax:
bool Uri.IsHexEncoding(string str, int index);
Parameter(s):
- string str – represents the string to be checked for hex encoding.
- int index – represents the index for given string.
Return value:
The return type of this method is boolean, it returns true if given string is hex-encoded otherwise returns false.
Example to demonstrate example of Uri.IsHexEncoding() method
using System;
class UriExample
{
//Entry point of Program
static public void Main()
{
string str1 = "%75";
string str2 = "75";
if (Uri.IsHexEncoding(str1, 0))
Console.WriteLine("Given string is hex-encoded");
else
Console.WriteLine("Given string is not hex-encoded");
if (Uri.IsHexEncoding(str2, 0))
Console.WriteLine("Given string is hex-encoded");
else
Console.WriteLine("Given string is not hex-encoded");
}
}
Output
Given string is hex-encoded
Given string is not hex-encoded