C# Uri IsHexEncoding
Description
Uri IsHexEncoding
determines whether a character in
a string is hexadecimal encoded.
Syntax
Uri.IsHexEncoding
has the following syntax.
public static bool IsHexEncoding(
string pattern,
int index
)
Parameters
Uri.IsHexEncoding
has the following parameters.
pattern
- The string to check.index
- The location in pattern to check for hexadecimal encoding.
Returns
Uri.IsHexEncoding
method returns A Boolean value that is true if pattern is hexadecimal encoded at the specified
location; otherwise, false.
Example
The following code example determines whether a character is hexadecimal encoded and, if so, writes the equivalent character to the console.
// w w w . j a va 2 s.c o m
using System;
public class MainClass{
public static void Main(String[] argv){
string testString = "%75";
int index = 0;
if (Uri.IsHexEncoding(testString, index))
Console.WriteLine("The character is {0}", Uri.HexUnescape(testString, ref index));
else
Console.WriteLine("The character is not hexadecimal encoded");
}
}
The code above generates the following result.