System.Text.EncodingNLS.GetChars C# (CSharp) Метод

GetChars() приватный Метод

private GetChars ( byte bytes, int byteIndex, int byteCount, char chars, int charIndex ) : int
bytes byte
byteIndex int
byteCount int
chars char
charIndex int
Результат int
        public unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount,
                                              char[] chars, int charIndex)
        {
            // Validate Parameters
            if (bytes == null || chars == null)
                throw new ArgumentNullException(bytes == null ? nameof(bytes): nameof(chars), SR.ArgumentNull_Array);

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

            if (bytes.Length - byteIndex < byteCount)
                throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer);

            if (charIndex < 0 || charIndex > chars.Length)
                throw new ArgumentOutOfRangeException(nameof(charIndex), SR.ArgumentOutOfRange_Index);
            Contract.EndContractBlock();

            // If no input, return 0 & avoid fixed problem
            if (bytes.Length == 0)
                return 0;

            // Just call pointer version
            int charCount = chars.Length - charIndex;

            // Fixed doesn't like empty arrays
            if (chars.Length == 0)
                chars = new char[1];

            fixed (byte* pBytes = bytes)
                fixed (char* pChars = chars)
                    // Remember that charCount is # to decode, not size of array
                    return GetChars(pBytes + byteIndex, byteCount,
                                    pChars + charIndex, charCount, null);
        }

Same methods

EncodingNLS::GetChars ( byte bytes, int byteCount, char chars, int charCount ) : int
EncodingNLS::GetChars ( byte bytes, int byteCount, char chars, int charCount, DecoderNLS decoder ) : int

Usage Example

Пример #1
0
        public override unsafe int GetChars(byte *bytes, int byteCount,
                                            char *chars, int charCount, bool flush)
        {
            if (bytes is null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }

            if (chars is null)
            {
                throw new ArgumentNullException(nameof(chars));
            }

            if (byteCount < 0 || charCount < 0)
            {
                throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum);
            }

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

            // By default just call the encoding's version
            return(m_encoding.GetChars(bytes, byteCount, chars, charCount, this));
        }
All Usage Examples Of System.Text.EncodingNLS::GetChars