<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="10.0.0-preview.1.25080.5" />

HexConverter

static class HexConverter
using System.Runtime.CompilerServices; namespace System { internal static class HexConverter { public enum Casing : uint { Upper = 0, Lower = 8224 } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ToCharsBuffer(byte value, Span<char> buffer, int startingIndex = 0, Casing casing = Casing.Upper) { uint num = (uint)(((value & 240) << 4) + (value & 15) - 35209); uint num2 = (uint)((int)((((0 - num) & 28784) >> 4) + num + 47545) | (int)casing); buffer[startingIndex + 1] = (char)(num2 & 255); buffer[startingIndex] = (char)(num2 >> 8); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int FromLowerChar(int c) { if ((uint)(c - 48) <= 9) return c - 48; if ((uint)(c - 97) <= 5) return c - 97 + 10; return 255; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsHexLowerChar(int c) { if ((uint)(c - 48) > 9) return (uint)(c - 97) <= 5; return true; } } }