© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
22 replies
MarkusSchaber

❔ How to convert a hex string to a Span<byte>?

Is there an allocation free method to convert a hex string into the corresponding bytes without allocation? I already have a Span<byte> as the destination, but
Convert.FromHexString(...)
Convert.FromHexString(...)
insists on returning a newly allocated byte array.
BitConverter
BitConverter
also has no useful methods, it seems.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Convert Span<string> to Span<object>
C#CC# / help
3mo ago
Convert Uint64 to Hex String Help
C#CC# / help
4y ago
Convert int[] to byte[]?
C#CC# / help
4y ago