System.Text.DecoderExceptionFallbackBuffer.Throw C# (CSharp) Method

Throw() private method

private Throw ( byte bytesUnknown, int index ) : void
bytesUnknown byte
index int
return void
        private void Throw(byte[] bytesUnknown, int index)
        {
            // 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++)
            {
                strBytes.Append("[");
                strBytes.Append(bytesUnknown[i].ToString("X2", CultureInfo.InvariantCulture));
                strBytes.Append("]");
            }
            
            // In case the string's really long
            if (i == 20)
                strBytes.Append(" ...");

            // Known index
            throw new DecoderFallbackException(
                Environment.GetResourceString("Argument_InvalidCodePageBytesIndex",
                   strBytes, index), bytesUnknown, index);           
        }