How to create a stream from a string in .Net

Yesterday I needed a way to take a string and create a stream from it. I did some searching but I didn't find any clean way. Here what I came up with in C#:

Stream s = new MemoryStream(ASCIIEncoding.Default.GetBytes("Test String"));

Does anyone know of any better or the recommended way to do this?

Why doesn't .Net have a string stream class?


Comments have been disabled for this content.