CharUnicodeInfo.GetDecimalDigitValue Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar decimaltecknet för ett numeriskt Unicode-tecken.
Överlagringar
| Name | Description |
|---|---|
| GetDecimalDigitValue(Char) |
Hämtar decimaltecknet för det angivna numeriska tecknet. |
| GetDecimalDigitValue(String, Int32) |
Hämtar decimaltecknets värde för det numeriska tecknet vid det angivna indexet för den angivna strängen. |
GetDecimalDigitValue(Char)
- Källa:
- CharUnicodeInfo.cs
- Källa:
- CharUnicodeInfo.cs
- Källa:
- CharUnicodeInfo.cs
- Källa:
- CharUnicodeInfo.cs
- Källa:
- CharUnicodeInfo.cs
Hämtar decimaltecknet för det angivna numeriska tecknet.
public:
static int GetDecimalDigitValue(char ch);
public static int GetDecimalDigitValue(char ch);
static member GetDecimalDigitValue : char -> int
Public Shared Function GetDecimalDigitValue (ch As Char) As Integer
Parametrar
- ch
- Char
Unicode-tecknet för vilket decimaltecknet ska hämtas.
Returer
Decimaltalsvärdet för det angivna numeriska tecknet.
-eller-
-1, om det angivna tecknet inte är en decimalsiffra.
Exempel
I följande kodexempel visas de värden som returneras av varje metod för olika typer av tecken.
using System;
using System.Globalization;
public class SamplesCharUnicodeInfo {
public static void Main() {
Console.WriteLine( " c Num Dig Dec UnicodeCategory" );
Console.Write( "U+0061 LATIN SMALL LETTER A " );
PrintProperties( 'a' );
Console.Write( "U+0393 GREEK CAPITAL LETTER GAMMA " );
PrintProperties( '\u0393' );
Console.Write( "U+0039 DIGIT NINE " );
PrintProperties( '9' );
Console.Write( "U+00B2 SUPERSCRIPT TWO " );
PrintProperties( '\u00B2' );
Console.Write( "U+00BC VULGAR FRACTION ONE QUARTER " );
PrintProperties( '\u00BC' );
Console.Write( "U+0BEF TAMIL DIGIT NINE " );
PrintProperties( '\u0BEF' );
Console.Write( "U+0BF0 TAMIL NUMBER TEN " );
PrintProperties( '\u0BF0' );
Console.Write( "U+0F33 TIBETAN DIGIT HALF ZERO " );
PrintProperties( '\u0F33' );
Console.Write( "U+2788 CIRCLED SANS-SERIF DIGIT NINE " );
PrintProperties( '\u2788' );
}
public static void PrintProperties( char c ) {
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 ) );
}
}
/*
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 Γ -1 -1 -1 UppercaseLetter
U+0039 DIGIT NINE 9 9 9 9 DecimalDigitNumber
U+00B2 SUPERSCRIPT TWO ² 2 2 -1 OtherNumber
U+00BC VULGAR FRACTION ONE QUARTER ¼ 0.25 -1 -1 OtherNumber
U+0BEF TAMIL DIGIT NINE ௯ 9 9 9 DecimalDigitNumber
U+0BF0 TAMIL NUMBER TEN ௰ 10 -1 -1 OtherNumber
U+0F33 TIBETAN DIGIT HALF ZERO ༳ -0.5 -1 -1 OtherNumber
U+2788 CIRCLED SANS-SERIF DIGIT NINE ➈ 9 9 -1 OtherNumber
*/
Imports System.Globalization
Public Class SamplesCharUnicodeInfo
Public Shared Sub Main()
Console.WriteLine(" c Num Dig Dec UnicodeCategory")
Console.Write("U+0061 LATIN SMALL LETTER A ")
PrintProperties("a"c)
Console.Write("U+0393 GREEK CAPITAL LETTER GAMMA ")
PrintProperties(ChrW(&H0393))
Console.Write("U+0039 DIGIT NINE ")
PrintProperties("9"c)
Console.Write("U+00B2 SUPERSCRIPT TWO ")
PrintProperties(ChrW(&H00B2))
Console.Write("U+00BC VULGAR FRACTION ONE QUARTER ")
PrintProperties(ChrW(&H00BC))
Console.Write("U+0BEF TAMIL DIGIT NINE ")
PrintProperties(ChrW(&H0BEF))
Console.Write("U+0BF0 TAMIL NUMBER TEN ")
PrintProperties(ChrW(&H0BF0))
Console.Write("U+0F33 TIBETAN DIGIT HALF ZERO ")
PrintProperties(ChrW(&H0F33))
Console.Write("U+2788 CIRCLED SANS-SERIF DIGIT NINE ")
PrintProperties(ChrW(&H2788))
End Sub
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
End Class
'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 Γ -1 -1 -1 UppercaseLetter
'U+0039 DIGIT NINE 9 9 9 9 DecimalDigitNumber
'U+00B2 SUPERSCRIPT TWO ² 2 2 -1 OtherNumber
'U+00BC VULGAR FRACTION ONE QUARTER ¼ 0.25 -1 -1 OtherNumber
'U+0BEF TAMIL DIGIT NINE ௯ 9 9 9 DecimalDigitNumber
'U+0BF0 TAMIL NUMBER TEN ௰ 10 -1 -1 OtherNumber
'U+0F33 TIBETAN DIGIT HALF ZERO ༳ -0.5 -1 -1 OtherNumber
'U+2788 CIRCLED SANS-SERIF DIGIT NINE ➈ 9 9 -1 OtherNumber
Kommentarer
Den här metoden konverterar tecken som representerar decimaltal till motsvarande integralvärden. Decimalsiffror är tecken i kategorin DecimalDigitNumber som kan representera en av tio siffror i decimaltalssystemet (bas 10), från noll till nio. Den innehåller tecken som U+0030 (DIGIT ZERO) via U+0039 (DIGIT NINE), U+0660 (ARABIC-INDIC DIGIT ZERO) via U+0669 (ARABIC-INDIC DIGIT NINE), U+07C0 (NKO DIGIT ZERO) till U+07C9 (NKO DIGIT NINE) och U+1040 (MYANMAR DIGIT ZERO) via U+1049 (MYANMAR DIGIT NINE).
Mer information om Unicode-tecken finns i Unicode Standard.
Gäller för
GetDecimalDigitValue(String, Int32)
- Källa:
- CharUnicodeInfo.cs
- Källa:
- CharUnicodeInfo.cs
- Källa:
- CharUnicodeInfo.cs
- Källa:
- CharUnicodeInfo.cs
- Källa:
- CharUnicodeInfo.cs
Hämtar decimaltecknets värde för det numeriska tecknet vid det angivna indexet för den angivna strängen.
public:
static int GetDecimalDigitValue(System::String ^ s, int index);
public static int GetDecimalDigitValue(string s, int index);
static member GetDecimalDigitValue : string * int -> int
Public Shared Function GetDecimalDigitValue (s As String, index As Integer) As Integer
Parametrar
- index
- Int32
Indexet för Unicode-tecknet för vilket decimaltecknet ska hämtas.
Returer
Decimaltecknets värde för det numeriska tecknet vid det angivna indexet för den angivna strängen.
-eller-
-1, om tecknet vid det angivna indexet för den angivna strängen inte är en decimalsiffra.
Undantag
s är null.
index ligger utanför intervallet för giltiga index i s.
Exempel
I följande kodexempel visas de värden som returneras av varje metod för olika typer av tecken.
using System;
using System.Globalization;
public class SamplesCharUnicodeInfo {
public static void Main() {
// The String to get information for.
String s = "a9\u0393\u00B2\u00BC\u0BEF\u0BF0\u2788";
Console.WriteLine( "String: {0}", s );
// Print the values for each of the characters in the string.
Console.WriteLine( "index c Num Dig Dec UnicodeCategory" );
for ( int i = 0; i < s.Length; i++ ) {
Console.Write( "{0,-5} {1,-3}", i, s[i] );
Console.Write( " {0,-5}", CharUnicodeInfo.GetNumericValue( s, i ) );
Console.Write( " {0,-5}", CharUnicodeInfo.GetDigitValue( s, i ) );
Console.Write( " {0,-5}", CharUnicodeInfo.GetDecimalDigitValue( s, i ) );
Console.WriteLine( "{0}", CharUnicodeInfo.GetUnicodeCategory( s, i ) );
}
}
}
/*
This code produces the following output. Some characters might not display at the console.
String: a9Γ²¼௯௰➈
index c Num Dig Dec UnicodeCategory
0 a -1 -1 -1 LowercaseLetter
1 9 9 9 9 DecimalDigitNumber
2 Γ -1 -1 -1 UppercaseLetter
3 ² 2 2 -1 OtherNumber
4 ¼ 0.25 -1 -1 OtherNumber
5 ௯ 9 9 9 DecimalDigitNumber
6 ௰ 10 -1 -1 OtherNumber
7 ➈ 9 9 -1 OtherNumber
*/
Imports System.Globalization
Public Class SamplesCharUnicodeInfo
Public Shared Sub Main()
' The String to get information for.
Dim s As [String] = "a9\u0393\u00B2\u00BC\u0BEF\u0BF0\u2788"
Console.WriteLine("String: {0}", s)
' Print the values for each of the characters in the string.
Console.WriteLine("index c Num Dig Dec UnicodeCategory")
Dim i As Integer
For i = 0 To s.Length - 1
Console.Write("{0,-5} {1,-3}", i, s(i))
Console.Write(" {0,-5}", CharUnicodeInfo.GetNumericValue(s, i))
Console.Write(" {0,-5}", CharUnicodeInfo.GetDigitValue(s, i))
Console.Write(" {0,-5}", CharUnicodeInfo.GetDecimalDigitValue(s, i))
Console.WriteLine("{0}", CharUnicodeInfo.GetUnicodeCategory(s, i))
Next i
End Sub
End Class
'This code produces the following output. Some characters might not display at the console.
'
'String: a9Γ²¼௯௰➈
'index c Num Dig Dec UnicodeCategory
'0 a -1 -1 -1 LowercaseLetter
'1 9 9 9 9 DecimalDigitNumber
'2 Γ -1 -1 -1 UppercaseLetter
'3 ² 2 2 -1 OtherNumber
'4 ¼ 0.25 -1 -1 OtherNumber
'5 ௯ 9 9 9 DecimalDigitNumber
'6 ௰ 10 -1 -1 OtherNumber
'7 ➈ 9 9 -1 OtherNumber
Kommentarer
Den här metoden konverterar tecken som representerar decimaltal till motsvarande integralvärden. Decimalsiffror är tecken i kategorin DecimalDigitNumber som kan representera en av tio siffror i decimaltalssystemet (bas 10), från noll till nio. Den innehåller tecken som U+0030 (DIGIT ZERO) via U+0039 (DIGIT NINE), U+0660 (ARABIC-INDIC DIGIT ZERO) via U+0669 (ARABIC-INDIC DIGIT NINE), U+07C0 (NKO DIGIT ZERO) till U+07C9 (NKO DIGIT NINE) och U+1040 (MYANMAR DIGIT ZERO) via U+1049 (MYANMAR DIGIT NINE).
Mer information om Unicode-tecken finns i Unicode Standard.