共用方式為


NumberFormatInfo.NativeDigits 屬性

定義

取得或設定字串陣列,其中包含對等於西方數字 0 到 9 之當地慣用的數字。

public:
 property cli::array <System::String ^> ^ NativeDigits { cli::array <System::String ^> ^ get(); void set(cli::array <System::String ^> ^ value); };
public string[] NativeDigits { get; set; }
[System.Runtime.InteropServices.ComVisible(false)]
public string[] NativeDigits { get; set; }
member this.NativeDigits : string[] with get, set
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.NativeDigits : string[] with get, set
Public Property NativeDigits As String()

屬性值

String[]

字串陣列,其中包含對等於西方數字 0 到 9 之當地慣用的數字。 預設值是具有項目 "0"、"1"、"2"、"3"、"4"、"5"、"6"、"7"、"8" 和 "9" 的陣列。

屬性

例外狀況

目前的 NumberFormatInfo 物件是唯讀的。

在設定作業中,此值為 null

-或-

在設定作業中,數值陣列的項目是 null

在設定作業中,數值陣列不包含 10 個項目。

-或-

在設定作業中,數值陣列項目不包含單一的 Char 物件,或由 Surrogate 字組組成的一對 Char 物件。

-或-

在設定作業中,數值陣列項目與由 Unicode 標準所定義的數字不同。 亦即,陣列項目中的數字沒有 Unicode Number, Decimal Digit (Nd) 一般類別值。

-或-

在設定作業中,數值陣列的項目數值不符合陣列中項目的位置。 亦即,位於索引 0 的項目,即陣列的第一個項目,沒有數值 0;或是位於索引 1 的項目,沒有數值 1。

範例

下列範例示範 NativeDigits 屬性。

// This example demonstrates the NativeDigits property.

using namespace System;
using namespace System::Globalization;
using namespace System::Threading;

int main()
{
    CultureInfo^ currentCI = Thread::CurrentThread->CurrentCulture;
    NumberFormatInfo^ nfi = currentCI->NumberFormat;
    array<String^>^ nativeDigitList = nfi->NativeDigits;

    Console::WriteLine("The native digits for the {0} culture are:",
        currentCI->Name);

    for each (String^ nativeDigit in nativeDigitList)
    {
        Console::Write("\"{0}\" ", nativeDigit);
    }

    Console::WriteLine();
}
/*
This code example produces the following results:

The native digits for the en-US culture are:
"0" "1" "2" "3" "4" "5" "6" "7" "8" "9"

*/
// This example demonstrates the NativeDigits property.

using System;
using System.Globalization;
using System.Threading;

class Sample
{
    public static void Main()
    {
    CultureInfo currentCI = Thread.CurrentThread.CurrentCulture;
    NumberFormatInfo nfi = currentCI.NumberFormat;
    string[] nativeDigitList = nfi.NativeDigits;

    Console.WriteLine("The native digits for the {0} culture are:", currentCI.Name);
    foreach (string s in nativeDigitList)
        {
        Console.Write("\"{0}\" ", s);
        }
    Console.WriteLine();
    }
}
/*
This code example produces the following results:

The native digits for the en-US culture are:
"0" "1" "2" "3" "4" "5" "6" "7" "8" "9"

*/
' This example demonstrates the NativeDigits property.

Imports System.Globalization
Imports System.Threading

Class Sample
    Public Shared Sub Main() 
        Dim currentCI As CultureInfo = Thread.CurrentThread.CurrentCulture
        Dim nfi As NumberFormatInfo = currentCI.NumberFormat
        Dim nativeDigitList As String() = nfi.NativeDigits
        
        Console.WriteLine("The native digits for the {0} culture are:", currentCI.Name)
        Dim s As String
        For Each s In  nativeDigitList
            Console.Write("""{0}"" ", s)
        Next s
        Console.WriteLine()
    
    End Sub
End Class

'This code example produces the following results:
'
'The native digits for the en-US culture are:
'"0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
'

備註

重要

屬性所 NativeDigits 指定的字元集不會影響剖析或格式化作業。 格式化或剖析數值或日期和時間值時,只會使用基本拉丁數位 0 (U+0030) 到 9 (U+0039) 。

適用於

另請參閱