System.Text.EncodingNLS.ThrowCharsOverflow C# (CSharp) Method

ThrowCharsOverflow() private method

private ThrowCharsOverflow ( ) : void
return void
        internal void ThrowCharsOverflow()
        {
            // Special message to include fallback type in case fallback's GetMaxCharCount is broken
            // This happens if user has implemented a decoder fallback with a broken GetMaxCharCount
            throw new ArgumentException(SR.Format(SR.Argument_EncodingConversionOverflowChars, EncodingName, DecoderFallback.GetType()), "chars");
        }

Same methods

EncodingNLS::ThrowCharsOverflow ( DecoderNLS decoder, bool nothingDecoded ) : void

Usage Example

        internal unsafe bool AddChar(char ch, int numBytes)
        {
            if (_chars != null)
            {
                if (_chars >= _charEnd)
                {
                    // Throw maybe
                    _bytes -= numBytes;                                      // Didn't encode these bytes
                    _enc.ThrowCharsOverflow(_decoder, _bytes <= _byteStart); // Throw?
                    return(false);                                           // No throw, but no store either
                }

                *(_chars++) = ch;
            }
            _charCountResult++;
            return(true);
        }