String to a Stream

The time has come where I needed to handle streams, so the first I needed to generate some tests and within these tests I need to generate a stream based on some text.  So the first task was to convert a String in to a Stream, and while I am at it how about the other direction to (Stream to a String)

String in to a Stream

[code language=C#]

string text = “To Jani, Reminder Don’t forget me this weekend!'”;
byte[] byteArray = Encoding.ASCII.GetBytes(text);
MemoryStream streamXML = new MemoryStream(byteArray);

[/code]

Stream to a String

[code language=C#]

xml.Seek(0, SeekOrigin.Begin);
var readerXML = new StreamReader(xml);
string textXML = readerXML.ReadToEnd();

[/code]