Exemple #1
0
        char ReadChar(this byte[] arr, int offset, bool little)
        {
#if SAFE_CAST
#if PROFILER
            Profiler.BeginSample("ReadChar");
#endif

            char s;
            fixed(byte *bytes = arr)
            {
                char *databytes = (char *)(bytes + offset);

                s = *databytes;
            }

            if (BitConverter.IsLittleEndian != little)
            {
                Reverse2(&s);
            }

#if PROFILER
            Profiler.EndSample();
#endif
            return(s);
#else
            if (BitConverter.IsLittleEndian == little)
            {
                CharField fs = new CharField(arr, offset);
                return(fs.CharVal);
            }
            else
            {
                RCharField fs = new RCharField(arr, offset);
                return(fs.CharVal);
            }
#endif
        }