System.Text.DecoderFallbackBuffer.ThrowLastBytesRecursive C# (CSharp) Method

ThrowLastBytesRecursive() private method

private ThrowLastBytesRecursive ( byte bytesUnknown ) : void
bytesUnknown byte
return void
        internal void ThrowLastBytesRecursive(byte[] bytesUnknown)
        {
            // Create a string representation of our bytes.
            StringBuilder strBytes = new StringBuilder(bytesUnknown.Length * 3);
            int i;
            for (i = 0; i < bytesUnknown.Length && i < 20; i++)
            {
                if (strBytes.Length > 0)
                    strBytes.Append(" ");
                strBytes.Append(String.Format(CultureInfo.InvariantCulture, "\\x{0:X2}", bytesUnknown[i]));
            }
            // In case the string's really long
            if (i == 20)
                strBytes.Append(" ...");

            // Throw it, using our complete bytes
            throw new ArgumentException(
                Environment.GetResourceString("Argument_RecursiveFallbackBytes",
                    strBytes.ToString()), "bytesUnknown");
        }