FromHex Method

Uri.FromHex Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the decimal value of a hexadecimal digit.

Namespace:  System
Assembly:  System (in System.dll)

'Declaration
Public Shared Function FromHex ( _
	digit As Char _
) As Integer

Parameters

digit
Type: System.Char
The hexadecimal digit (0-9, a-f, A-F) to convert.

Return Value

Type: System.Int32
An Int32 value that contains a number from 0 to 15 that corresponds to the specified hexadecimal digit.

ExceptionCondition
ArgumentException

digit is not a valid hexadecimal digit (0-9, a-f, A-F).

The FromHex method converts a character representing a hexadecimal digit (0-9, a-f, A-F) to its decimal value (0 to 15). If digit is not a valid hexadecimal digit, an ArgumentException exception is thrown.

The following example determines whether a character is a hexadecimal character and, if it is, writes the corresponding decimal value to the console.


Dim testChar As Char = "e"
If Uri.IsHexDigit(testChar) = True Then 
  outputBlock.Text &= testChar
  outputBlock.Text &= "is the hexadecimal representation of "
  outputBlock.Text &= Uri.FromHex(testChar)
  outputBlock.Text &= vbCrLf
Else
  outputBlock.Text &= testChar
  outputBlock.Text &= "is not a hexadecimal character"
  outputBlock.Text &= vbCrLf
End If


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft