namespaceSystem{// NEW type[Flags]publicenumHexFormattingOptions{None=0,InsertLineBreaks=1,Lowercase=2}// NEW methods on EXISTING typepublicstaticclassConvert{// Decode from charspublicstaticbyte[]FromHexCharArray(char[]inArray,intoffset,intlength)=>thrownull;publicstaticboolTryFromHexChars(ReadOnlySpan<char>chars,Span<byte>bytes,outintbytesWritten)=>thrownull;// Decode from stringspublicstaticbyte[]FromHexString(strings)=>thrownull;publicstaticbyte[]FromHexString(ReadOnlySpan<char>chars)=>thrownull;publicstaticboolTryFromHexString(strings,Span<byte>bytes,outintbytesWritten)=>thrownull;// Encode to charspublicstaticintToHexCharArray(byte[]inArray,intoffsetIn,intlength,char[]outArray,intoffsetOut,HexFormattingOptionsoptions=default)=>thrownull;publicstaticboolTryToHexChars(ReadOnlySpan<byte>bytes,Span<char>chars,outintcharsWritten,HexFormattingOptionsoptions=default)=>thrownull;// Encode to stringspublicstaticstringToHexString(byte[]inArray,HexFormattingOptionsoptions=default)=>thrownull;publicstaticstringToHexString(byte[]inArray,intoffset,intlength,HexFormattingOptionsoptions=default)=>thrownull;publicstaticstringToHexString(ReadOnlySpan<byte>bytes,HexFormattingOptionsoptions=default)=>thrownull;}}namespace System.Buffers.Text
{// NEW typepublicstaticclassHex{// Decodepublicstatic OperationStatus DecodeFromUtf8(ReadOnlySpan<byte>utf8,Span<byte>bytes,outintbytesConsumed,outintbytesWritten,boolisFinalBlock=true)=>thrownull;publicstatic OperationStatus DecodeFromUtf8InPlace(Span<byte>buffer,outintbytesWritten)=>thrownull;// Encodepublicstatic OperationStatus EncodeToUtf8(ReadOnlySpan<byte>bytes,Span<byte>utf8,outintbytesConsumed,outintbytesWritten,boolisFinalBlock=true)=>thrownull;publicstatic OperationStatus EncodeToUtf8InPlace(Span<byte>buffer,intdataLength,outintbytesWritten)=>thrownull;}}
Performance characteristics
BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19041.207 (2004/?/20H1)
Intel Core i7-9750H CPU 2.60GHz, 1 CPU, 12 logical and 6 physical cores
.NET Core SDK=5.0.100-preview.2.20176.6