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 对象或一对构成代理项对的 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) 。

适用于

另请参阅