Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CharUnicodeInfo.GetDigitValue Method (Char)

Gets the digit value of the specified numeric character.

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

Public Shared Function GetDigitValue ( _
	ch As Char _
) As Integer


Type: System.Char

The Unicode character for which to get the digit value.

Return Value

Type: System.Int32
The digit value of the specified numeric character.
-1, if the specified character is not a digit.

Digit value is a property that applies only to numeric characters that can be used as digits. A digit is a numeric character that can be combined with other digits to represent a whole number in a numbering system.

For more information on Unicode characters, see the Unicode Standard.

The following code example shows the values returned by each method for different types of characters.

Imports System
Imports System.Globalization
Imports Microsoft.VisualBasic

Public Class SamplesCharUnicodeInfo   

   Public Shared Sub Main()

      Console.WriteLine("                                        c  Num   Dig   Dec   UnicodeCategory")

      Console.Write("U+0061 LATIN SMALL LETTER A            ")

      Console.Write("U+0393 GREEK CAPITAL LETTER GAMMA      ")

      Console.Write("U+0039 DIGIT NINE                      ")

      Console.Write("U+00B2 SUPERSCRIPT TWO                 ")

      Console.Write("U+00BC VULGAR FRACTION ONE QUARTER     ")

      Console.Write("U+0BEF TAMIL DIGIT NINE                ")

      Console.Write("U+0BF0 TAMIL NUMBER TEN                ")

      Console.Write("U+0F33 TIBETAN DIGIT HALF ZERO         ")

      Console.Write("U+2788 CIRCLED SANS-SERIF DIGIT NINE   ")

   End Sub 'Main

   Public Shared Sub PrintProperties(c As Char)
      Console.Write(" {0,-3}", c)
      Console.Write(" {0,-5}", CharUnicodeInfo.GetNumericValue(c))
      Console.Write(" {0,-5}", CharUnicodeInfo.GetDigitValue(c))
      Console.Write(" {0,-5}", CharUnicodeInfo.GetDecimalDigitValue(c))
      Console.WriteLine("{0}", CharUnicodeInfo.GetUnicodeCategory(c))
   End Sub 'PrintProperties

End Class 'SamplesCharUnicodeInfo 

'This code produces the following output.  Some characters might not display at the console. 

'                                        c  Num   Dig   Dec   UnicodeCategory 
'U+0061 LATIN SMALL LETTER A             a   -1    -1    -1   LowercaseLetter 
'U+0393 GREEK CAPITAL LETTER GAMMA       \u0393   -1    -1    -1   UppercaseLetter 
'U+0039 DIGIT NINE                       9   9     9     9    DecimalDigitNumber 
'U+00B2 SUPERSCRIPT TWO                  \u00B2   2     2     2    OtherNumber 
'U+00BC VULGAR FRACTION ONE QUARTER      \u00BC   0.25  -1    -1   OtherNumber 
'U+0BEF TAMIL DIGIT NINE                 \u0BEF   9     9     9    DecimalDigitNumber 
'U+0BF0 TAMIL NUMBER TEN                 \u0BF0   10    -1    -1   OtherNumber 
'U+0F33 TIBETAN DIGIT HALF ZERO          \u0F33   -0.5  -1    -1   OtherNumber 
'U+2788 CIRCLED SANS-SERIF DIGIT NINE    \u2788   9     9     -1   OtherNumber

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft