System.DateTimeFormat.FormatDigits C# (CSharp) Méthode

FormatDigits() private static méthode

private static FormatDigits ( StringBuilder outputBuffer, int value, int len ) : void
outputBuffer StringBuilder
value int
len int
Résultat void
        private unsafe static void FormatDigits(StringBuilder outputBuffer, int value, int len) {
            BCLDebug.Assert(value >= 0, "DateTimeFormat.FormatDigits(): value >= 0");

            // Limit the use of this function to be two-digits, so that we have the same behavior
            // as RTM bits.
            if (len > 2)
            {
                len = 2;
            }            

            char* buffer = stackalloc char[16];
            char* p = buffer + 16;
            int n = value;
            do {
                *--p = (char)(n % 10 + '0');
                n /= 10;
            } while ((n != 0)&&(p > buffer));
            
            int digits = (int) (buffer + 16 - p);
            
            //If the repeat count is greater than 0, we're trying
            //to emulate the "00" format, so we have to prepend
            //a zero if the string only has one character.
            while ((digits < len) && (p > buffer)) {
                *--p='0';
                digits++;
            }
            outputBuffer.Append(p, digits);
        }

Usage Example

 // Token: 0x060015DC RID: 5596 RVA: 0x000404BB File Offset: 0x0003E6BB
 internal static void FormatDigits(StringBuilder outputBuffer, int value, int len)
 {
     DateTimeFormat.FormatDigits(outputBuffer, value, len, false);
 }
All Usage Examples Of System.DateTimeFormat::FormatDigits