Convert String to Stream and stream to string

using System;
using System.IO;
using System.Text;
 
namespace streamDemo
{
class Program
{
static void Main( string[] args )
{
string str= "I love my India";
 
/*convert string to stream*/
byte[] byteArray = Encoding.ASCII.GetBytes( str);
MemoryStream stream = new MemoryStream( byteArray );
 
/* convert stream to string*/
StreamReader reader = new StreamReader( stream );
string text = reader.ReadToEnd();
 
Console.WriteLine(str);
Console.ReadLine();
}
}
}
Next Recommended Reading Return String Function in C#.Net