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

GetCharCount() private method

private GetCharCount ( byte bytes, int index, int count ) : int
bytes byte
index int
count int
return int
        public unsafe override int GetCharCount(byte[] bytes, int index, int count)
        {
            // Validate Parameters
            if (bytes == null)
                throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array);

            if (index < 0 || count < 0)
                throw new ArgumentOutOfRangeException((index < 0 ? nameof(index): nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum);

            if (bytes.Length - index < count)
                throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer);
            Contract.EndContractBlock();

            // If no input just return 0, fixed doesn't like 0 length arrays
            if (bytes.Length == 0)
                return 0;

            // Just call pointer version
            fixed (byte* pBytes = bytes)
                return GetCharCount(pBytes + index, count, null);
        }

Same methods

EncodingNLS::GetCharCount ( byte bytes, int count ) : int
EncodingNLS::GetCharCount ( byte bytes, int count, DecoderNLS decoder ) : int

Usage Example

示例#1
0
        public override unsafe int GetCharCount(byte *bytes, int count, bool flush)
        {
            if (bytes is null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }

            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
            }

            // Remember the flush
            m_mustFlush       = flush;
            m_throwOnOverflow = true;

            // By default just call the encoding version, no flush by default
            return(m_encoding.GetCharCount(bytes, count, this));
        }
All Usage Examples Of System.Text.EncodingNLS::GetCharCount