示例#1
0
        public static string?GetString(byte[] bytes)
        {
            if (bytes == null)
            {
                return(null);
            }

            if (bytes.Length == 0)
            {
                return(string.Empty);
            }

            var resultString = CoreLib.FastAllocateString(bytes.Length * 2);

            fixed(char *stringPtr = &resultString.GetPinnableReference())
            {
                var destUints = (uint *)stringPtr;

                for (var i = 0; i < bytes.Length; i++)
                {
                    destUints[i] = TableToHex[bytes[i]];
                }
            }

            return(resultString);
        }