다음을 통해 공유


Sys.CultureInfo.numberFormat 속성

업데이트: 2007년 11월

Number 형식 확장에 적용할 수 있는 문화권별 서식 및 구문 분석 문자열 값의 배열이 포함된 개체를 가져옵니다.

var cultureObject = Sys.CultureInfo.CurrentCulture;
var nfObject = cultureObject.numberFormat;

반환 값

문화권별 서식 문자열 배열을 포함하는 개체입니다.

설명

numberFormat 필드를 사용하면 현재 문화권 또는 고정 문화권에 따라 서식 문자열 배열을 포함하는 개체를 가져올 수 있습니다. 각 서식 문자열은 Number 형식 확장의 서식 지정 방법을 결정하는 데 사용됩니다.

예제

다음 예제에서는 현재 문화권에 따라 Sys.CultureInfo 클래스의 numberFormat 필드를 사용하는 방법을 보여 줍니다. 이때 Web.config 파일에서 <configuration> 섹션의 culture 특성이 "auto"로 설정되어 있어야 합니다. 문화권 설정에 대한 자세한 내용은 연습: 클라이언트 스크립트를 사용하여 날짜 전역화를 참조하십시오.

<script type="text/javascript">
    // Create the CurrentCulture object
    var cultureObject = Sys.CultureInfo.CurrentCulture;
    // Get the name field of the CurrentCulture object
    var cultureName = cultureObject.name;
    // Get the numberFormat object from the CurrentCulture object
    var nfObject = cultureObject.numberFormat;
    // Create an array of format types
    var myArray = ['CurrencyDecimalDigits', 'CurrencyDecimalSeparator', 'IsReadOnly', 'CurrencyGroupSizes',
                   'NumberGroupSizes', 'PercentGroupSizes', 'CurrencyGroupSeparator', 
                   'CurrencySymbol', 'NaNSymbol', 'CurrencyNegativePattern', 'NumberNegativePattern', 
                   'PercentPositivePattern', 'PercentNegativePattern', 'NegativeInfinitySymbol', 
                   'NegativeSign', 'NumberDecimalDigits', 'NumberDecimalSeparator', 
                   'NumberGroupSeparator', 'CurrencyPositivePattern', 'PositiveInfinitySymbol', 
                   'PositiveSign', 'PercentDecimalDigits', 'PercentDecimalSeparator', 
                   'PercentGroupSeparator', 'PercentSymbol', 'PerMilleSymbol', 
                   'NativeDigits', 'DigitSubstitution'];

    var result = 'Culture Name: ' + cultureName;
    for (var i = 0, l = myArray.length; i < l; i++) {
        var arrayVal = myArray[i];
        if (typeof(arrayVal) !== 'undefined') {
            result += "<tr><td>" + arrayVal + "</td><td>" + eval("nfObject." + arrayVal) + '</td></tr>';
        }
    }
    var resultHeader = "<tr><td><b>FormatType</b></td><td><b>FormatValue</b></td></tr>"
    $get('Label1').innerHTML = "<table border=1>" + resultHeader + result + "</table>";

    var n = 99.987;
    $get('Label2').innerHTML = "<p/><h3>numberFormat Example: </h3>" + 
    n.localeFormat("C");

 </script>
<script type="text/javascript">
    // Create the CurrentCulture object
    var cultureObject = Sys.CultureInfo.CurrentCulture;
    // Get the name field of the CurrentCulture object
    var cultureName = cultureObject.name;
    // Get the numberFormat object from the CurrentCulture object
    var nfObject = cultureObject.numberFormat;
    // Create an array of format types
    var myArray = ['CurrencyDecimalDigits', 'CurrencyDecimalSeparator', 'IsReadOnly', 'CurrencyGroupSizes',
                   'NumberGroupSizes', 'PercentGroupSizes', 'CurrencyGroupSeparator', 
                   'CurrencySymbol', 'NaNSymbol', 'CurrencyNegativePattern', 'NumberNegativePattern', 
                   'PercentPositivePattern', 'PercentNegativePattern', 'NegativeInfinitySymbol', 
                   'NegativeSign', 'NumberDecimalDigits', 'NumberDecimalSeparator', 
                   'NumberGroupSeparator', 'CurrencyPositivePattern', 'PositiveInfinitySymbol', 
                   'PositiveSign', 'PercentDecimalDigits', 'PercentDecimalSeparator', 
                   'PercentGroupSeparator', 'PercentSymbol', 'PerMilleSymbol', 
                   'NativeDigits', 'DigitSubstitution'];

    var result = 'Culture Name: ' + cultureName;
    for (var i = 0, l = myArray.length; i < l; i++) {
        var arrayVal = myArray[i];
        if (typeof(arrayVal) !== 'undefined') {
            result += "<tr><td>" + arrayVal + "</td><td>" + eval("nfObject." + arrayVal) + '</td></tr>';
        }
    }
    var resultHeader = "<tr><td><b>FormatType</b></td><td><b>FormatValue</b></td></tr>"
    $get('Label1').innerHTML = "<table border=1>" + resultHeader + result + "</table>";

    var n = 99.987;
    $get('Label2').innerHTML = "<p/><h3>numberFormat Example: </h3>" + 
    n.localeFormat("C");

 </script>

참고 항목

참조

Sys.CultureInfo 클래스

기타 리소스

언어 참조