title: Convert String to ReadOnlyMemory<byte> in C#?
body: <p>I would like to convert a String to a ReadOnlyMemory object. It's easy to convert a string to a ReadOnlyMemory object (using <a href="https://docs.microsoft.com/en-us/dotnet/api/system.memoryextensions.asmemory?view=net-5.0#system-memoryextensions-asmemory(system-string)" rel="nofollow noreferrer">.AsMemory()</a>) but there's no direct way to convert that to type byte, or directly convert the string otherwise.</p>