System.Xml.Xsl.Runtime.CharUtil.IsDecimalDigitOne C# (CSharp) Method

IsDecimalDigitOne() public static method

public static IsDecimalDigitOne ( char ch ) : bool
ch char
return bool
        public static bool IsDecimalDigitOne(char ch) {
            int category = (int)char.GetUnicodeCategory(--ch);
            return category == 8 && char.GetNumericValue(ch) == 0;
        }
    }

Usage Example

        private void FormatItem(StringBuilder sb, XPathItem item, char startChar, int length)
        {
            double dblVal;

            if (item.ValueType == typeof(int))
            {
                dblVal = (double)item.ValueAsInt;
            }
            else
            {
                Debug.Assert(item.ValueType == typeof(double), "Item must be either of type int, or double");
                dblVal = XsltFunctions.Round(item.ValueAsDouble);
            }

            Debug.Assert(1 <= dblVal && dblVal < double.PositiveInfinity);
            char zero = '0';

            switch (startChar)
            {
            case '1':
                break;

            case 'A':
            case 'a':
                if (dblVal <= MaxAlphabeticValue)
                {
                    ConvertToAlphabetic(sb, dblVal, startChar, 26);
                    return;
                }
                break;

            case 'I':
            case 'i':
                if (dblVal <= MaxRomanValue)
                {
                    ConvertToRoman(sb, dblVal, /*upperCase:*/ startChar == 'I');
                    return;
                }
                break;

            default:
                Debug.Assert(CharUtil.IsDecimalDigitOne(startChar), "Unexpected startChar: " + startChar);
                zero = (char)(startChar - 1);
                break;
            }

            sb.Append(ConvertToDecimal(dblVal, length, zero, _groupingSeparator, _groupingSize));
        }
All Usage Examples Of System.Xml.Xsl.Runtime.CharUtil::IsDecimalDigitOne