Daniel said:
in C# fastest way to convert a string into a MemoryStream
The simplest way is to pick a suitable encoding, use Encoding.GetBytes
to turn the string into a byte array, and create a MemoryStream
wrapping that byte array.
Assuming you really only need a Stream, however, there's a more
efficient way of doing it which is unfortunately a bit more work.
Create a StringReader from the Stream, and then (and this is the tricky
bit) write a class called ReaderStream or something similar which takes
a TextReader and an Encoding, and creates a Stream from it - you'll
need to maintain a buffer of unread bytes, and whenever you're asked to
read from the stream, either return data from that buffer or read from
the TextReader and encode the results to a byte array.
There may well already be such a class around, and it wouldn't be *too*
hard to write, but I'd stick with the first method unless efficiency is
really a big issue.