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
string text = “To Jani, Reminder Don’t forget me this weekend!'”;
byte[] byteArray = Encoding.ASCII.GetBytes(text);
MemoryStream streamXML = new MemoryStream(byteArray);
Stream to a String
xml.Seek(0, SeekOrigin.Begin);
var readerXML = new StreamReader(xml);
string textXML = readerXML.ReadToEnd();