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

GetByteCount() private method

private GetByteCount ( char chars, int index, int count ) : int
chars char
index int
count int
return int
        public unsafe override int GetByteCount(char[] chars, int index, int count)
        {
            // Validate input parameters
            if (chars == null)
                throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array);

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

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

            // If no input, return 0, avoid fixed empty array problem
            if (chars.Length == 0)
                return 0;

            // Just call the pointer version
            fixed (char* pChars = chars)
                return GetByteCount(pChars + index, count, null);
        }

Same methods

EncodingNLS::GetByteCount ( String s ) : int
EncodingNLS::GetByteCount ( char chars, int count ) : int
EncodingNLS::GetByteCount ( char chars, int count, EncoderNLS encoder ) : int

Usage Example

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

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

            m_mustFlush       = flush;
            m_throwOnOverflow = true;
            return(m_encoding.GetByteCount(chars, count, this));
        }
All Usage Examples Of System.Text.EncodingNLS::GetByteCount